如何配置WCF服务作为普通TCP服务器? [英] How to configure your WCF service to work as normal TCP server?

查看:324
本文介绍了如何配置WCF服务作为普通TCP服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将我的WCF服务配置为普通TCP服务器?是否可以禁用所有特定于绑定的内容,以便保留您的服务URL,如 http://example.com: 4444 / service 并且能够使用纯HTTP / TCP流吗?

How can I configure my WCF service to work as a normal TCP server? Is it possible to disable all that binding specific stuff so as to keep your service URL like http://example.com:4444/service and be able to work vith pure HTTP/TCP streams?

我需要能够与WCF服务一起使用TCP流。 ..所以我必须从我的一个WCF服务或(我不知道如何)使我的自托管WCF服务与我的独立TCP服务器配对工作。但是,我只是找不到如何让它们共享同一个端口,以便能够调用 http:/ /example.com:4444/WCFservice/ http://example.com:4444/TCPserver/ (我必须让他们分享它;不能选择2个端口。)

I need to be able to work with TCP streams in tandem with WCF services... so I have to make TCP server from one of my WCF services or (and I do not know how) make my self-hosted WCF services work in pair with my stand alone TCP server. However, I just can not find how to make them share the same port so as to be able to call http://example.com:4444/WCFservice/ http://example.com:4444/TCPserver/ (And I have to make them share it; taking 2 ports is not an option.)

推荐答案

最简单将TCP端点添加到服务的方法是修改关于WCF服务配置编辑器的web.config文件。您可以在web.config的上下文菜单中的Visual Studio的工具菜单中找到它(也在VS中)。您需要使用netTcpBinding添加新端点。此新端点的地址将以net.tcp://开头。有关详细信息,请参阅 http://msdn.microsoft.com/en-我们/库/ cc949080.aspx

The easiest way to add TCP endpoint to the service is modify you web.config file with respect of "WCF Service configuration editor". You can find it in the "Tools" menu of Visual Studio of in context menu of web.config (also in VS). You need add new endpoint with netTcpBinding. The address of such new endpoint will be start with "net.tcp://". For more information you can read http://msdn.microsoft.com/en-us/library/cc949080.aspx.

对于net.tcp端口共享,读取 http://msdn.microsoft.com/en-us/library/aa395195.aspx 或google for:wcf tcp端口端口共享。

For net.tcp port sharing read http://msdn.microsoft.com/en-us/library/aa395195.aspx or google for: wcf tcp endpoint port sharing.

您可以在 http:/中找到有关WCF 4新功能的详细介绍/msdn.microsoft.com/en-us/library/ee354381.aspx

如果有人不了解WCF的优势与之相比,那么请放轻松Winsocket编程。 15年前我使用了插座,发现很酷。然后我使用了RPC,DCOM等。如果你考虑端点的身份验证,现在WCF是最好的方法。所以以前的评论很简单。

And take it easy if somebody don't understand advantages of WCF compares with Winsocket programming. 15 year ago I used sockets and find it cool. Then I used RPC, DCOM etc. Now WCF is the best way if you think about authentication of your endpoint. So take some of previous comments easy.

这篇关于如何配置WCF服务作为普通TCP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆