Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a WCF Service replace the functionality of TCPListener?

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 with a WCF service without any change to the clients? If so can anyone suggest resources which would help me to construct such a service?

like image 490
Andrew Avatar asked Sep 07 '10 15:09

Andrew


2 Answers

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.

like image 118
Ladislav Mrnka Avatar answered Nov 18 '22 15:11

Ladislav Mrnka


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.

like image 38
Sajay Avatar answered Nov 18 '22 15:11

Sajay