简体   繁体   English

如何配置WCF服务以用作普通TCP服务器?

[英]How to configure your WCF service to work as normal TCP server?

How can I configure my WCF service to work as a normal TCP server? 如何配置WCF服务以用作普通TCP服务器? 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? 是否可以禁用所有绑定特定的东西,以使您的服务URL像http://example.com:4444/service一样,并能够通过纯HTTP / TCP流工作?

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. 我需要能够与WCF服务一道使用TCP流...因此,我必须从我的WCF服务之一制作TCP服务器,或者(而且我不知道如何)使我的自托管WCF服务成对工作。与我的独立TCP服务器一起使用。 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.) 但是,我只是找不到如何使它们共享相同的端口,以便能够调用http://example.com:4444/WCFservice/ http://example.com:4444/TCPserver/ (让他们共享它;不能选择2个端口。)

If you want to work with pure TCP streams you'd probably work with sockets directly and not WCF. 如果要使用纯TCP流,则可能直接使用套接字而不是WCF。

Use WCF when you want things auto implemented for you at the transport layer. 当您希望在传输层为您自动实现事物时,请使用WCF。

The easiest way to add TCP endpoint to the service is modify you web.config file with respect of "WCF Service configuration editor". 将TCP端点添加到服务的最简单方法是根据“ WCF服务配置编辑器”修改web.config文件。 You can find it in the "Tools" menu of Visual Studio of in context menu of web.config (also in VS). 您可以在web.config的上下文菜单(同样在VS中)的Visual Studio的“工具”菜单中找到它。 You need add new endpoint with netTcpBinding. 您需要使用netTcpBinding添加新端点。 The address of such new endpoint will be start with "net.tcp://". 这样的新端点的地址将以“ net.tcp://”开头。 For more information you can read http://msdn.microsoft.com/en-us/library/cc949080.aspx . 有关更多信息,您可以阅读http://msdn.microsoft.com/en-us/library/cc949080.aspx

For net.tcp port sharing read http://msdn.microsoft.com/en-us/library/aa395195.aspx or google for: wcf tcp endpoint port sharing. 对于net.tcp端口共享,请阅读http://msdn.microsoft.com/zh-cn/library/aa395195.aspx或google,以获取:wcf tcp端点端口共享。

A good review of new features of WCF 4 you can find in http://msdn.microsoft.com/en-us/library/ee354381.aspx 您可以在http://msdn.microsoft.com/zh-cn/library/ee354381.aspx中找到有关WCF 4的新功能的很好的评论。

And take it easy if somebody don't understand advantages of WCF compares with Winsocket programming. 如果有人不了解WCF与Winsocket编程的优势,请放轻松。 15 year ago I used sockets and find it cool. 15年前,我使用插座,发现它很酷。 Then I used RPC, DCOM etc. Now WCF is the best way if you think about authentication of your endpoint. 然后,我使用了RPC,DCOM等。现在,如果您考虑对端点进行身份验证,那么WCF是最好的方法。 So take some of previous comments easy. 因此,使以前的一些评论变得容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM