Wcf – How to host WCF through TCP ports

net.tcptcpwcfwcf-binding

How do I host WCF services through TCP Ports, and how do I listen to it and consume services through these TCP ports?

That is, apart from the net.tcp binding, is there some way to host and consume using TCP ports?

Best Answer

In WCF, you can host any service by yourself by creating an instance of the ServiceHost class, configure it with the correct endpoints and the service implementation you wish to expose, and call Open on it. This is called self-hosting because you host the service (and its port listeners) from within your own application.

Alternatively, you can host your service in IIS, but you should be aware that while you can host WCF in IIS 6, it only allows you to host HTTP and HTTPS endpoints. If you want to host TCP endpoints in IIS (which is a good idea), you will need IIS 7.

Read more here.