开发者

Can a WCF Service replace the functionality of TCPListener?

开发者 https://www.devze.com 2023-01-15 17:44 出处:网络
I have a TCPListener based server application which listens for clients on a single specific port. The clients connect, send some xml, get some xml back as a response and then disconnect.

I have a TCPListener based server application which listens for clients on a single specific port. The clients connect, send some xml, get some xml back as a response and then disconnect.

Is it at all possible to replace the TCPListener based application w开发者_如何学Goith a WCF service without any change to the clients? If so can anyone suggest resources which would help me to construct such a service?


Theoretically Yes. WCF has many extensibility points so you can include your own message encoder, your own transport channel etc. You can include custom behavior to affect message format etc. You should be able to do that even if you have proprietary message format or transport protocol. But it is a lot of work.

If you really want to try it you can start with custom message encoder which will take Message and write it as your custom XML format to binary encoder. Combine this new encoder in custom binding with build in tcpTransport. It will be hard to debug. Samples provides example of adding JSONP support. I think it is similar approach. It uses build in transport and encoder and it adds custom message formatting.


A simple tcp based server does not follow the message framing protocol that net.tcp for wcf follows http://blogs.msdn.com/b/drnick/archive/2009/01/19/message-framing-part-1.aspx.

This is what makes it really hard to implement a WCF that can talk to clients that use a custom TCP Listener service with your own messaging scheme.

0

精彩评论

暂无评论...
验证码 换一张
取 消