views:

40

answers:

2

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?

+2  A: 

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.

Ladislav Mrnka
Sounds like a lot of work for little to no benefit, the TCPListener solution works well, I was just curious if it was possible.
Andrew
A: 

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.

Sajay