How to host WCF through TCP ports?

kurozakura picture kurozakura · Jun 29, 2009 · Viewed 25.7k times · Source

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?

Answer

Mark Seemann picture Mark Seemann · Jun 29, 2009

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.