How to host WCF through TCP ports?

25,821

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.

Share:
25,821
kurozakura
Author by

kurozakura

Updated on August 01, 2020

Comments

  • kurozakura
    kurozakura almost 4 years

    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?

    • kurozakura
      kurozakura almost 15 years
      so basically,in windows xp hosting n consuming can be done in 3 ways 1.self-hosting 2.IIS 3.as a Windows Service so opening a TCP port and consuming it,comes under self-hosting or is it another way of hosting n consuming wcf services or is there any other way i.e under TCP?
  • kurozakura
    kurozakura almost 15 years
    so basically,in windows xp hosting n consuming can be done in 3 ways 1.self-hosting 2.IIS 3.as a Windows Service so opening a TCP port and consuming it,comes under self-hosting or is it another way of hosting n consuming wcf services or is there any other way?
  • kurozakura
    kurozakura almost 15 years
    so basically,in windows xp hosting n consuming can be done in 3 ways 1.self-hosting 2.IIS 3.as a Windows Service so opening a TCP port and consuming it,comes under self-hosting or is it another way of hosting n consuming wcf services or is there any other way i.e under TCP?
  • kurozakura
    kurozakura almost 15 years
    so basically,in windows xp hosting n consuming can be done in 3 ways 1.self-hosting 2.IIS 3.as a Windows Service so opening a TCP port and consuming it,comes under self-hosting or is it another way of hosting n consuming wcf services or is there any other way i.e under TCP?
  • Mark Seemann
    Mark Seemann almost 15 years
    Windows XP doesn't run IIS 7, so you can't host a TCP endpoint on IIS under XP. You can make a Windows Service host a WCF service, but that's just another example of Self Hosting.
  • Tad Donaghe
    Tad Donaghe almost 15 years
    I think you can host TCP with WAS in IIS 7.
  • Asela Liyanage
    Asela Liyanage almost 15 years
    HTTP is an application protocol, not transport.
  • Darren Oster
    Darren Oster over 14 years
    More info on using netsh to open a port here: msdn.microsoft.com/en-us/library/ms733768.aspx