Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to host WCF through TCP ports?

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?

like image 983
kurozakura Avatar asked Jun 29 '09 07:06

kurozakura


People also ask

What is WCF service TCP port sharing?

Windows Communication Foundation (WCF) provides a new TCP-based network protocol (net. tcp://) for high-performance communication. WCF also introduces a new system component, the Net. TCP Port Sharing Service that enables net. tcp ports to be shared across multiple user processes.

How do I enable TCP port sharing?

In the Name column of the list of services, right-click the Net. Tcp Port Sharing Service, and select Properties from the menu. To enable the manual start-up of the service, in the Properties window select the General tab, and in the Startup type box select Manual, and then click Apply.

How do I host WCF on local machine?

Open WCF Test Client. To open WCF Test Client, open Developer Command Prompt for Visual Studio and execute WcfTestClient.exe. Select Add Service from the File menu. Type http://localhost:8080/hello into the address box and click OK.


1 Answers

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.

like image 112
Mark Seemann Avatar answered Nov 15 '22 07:11

Mark Seemann