Because of a certain requirement i need to have a service listening on port 443 (an maybe 80) to coexist with IIS on a same windows 2008 server. Its possible to have a Windows Service Hosted WCF service to share port 80 with IIS but i was wondering if this is possible to do in a C++ service? I've read answers about similar questions like this, this and this but i still haven't got an appropriate answer.
Asked
Active
Viewed 1,122 times
2
-
I don't understand your question: which process would reply to a given request? – curiousguy Dec 08 '11 at 15:19
-
I'm not sure how the process is being selected. but i would like to learn how is this being done in Net.Tcp Port Sharing and if its possible to use this feature in other non-WCF services. – red.clover Dec 11 '11 at 03:35
-
I don't know what "Net.Tcp Port Sharing" is, and I don't understand how it matters to you. What is your specification? what are you really trying to do? Are you trying to emulate "Net.Tcp Port Sharing"? – curiousguy Dec 12 '11 at 00:12
1 Answers
2
Only one application may be bound to an ip-address/port-number pair. If a socket is bound to INADDR_ANY and some port, then no other application my bind to that port.
If you want two applications to receive data on a port, you need some kind of proxy that listens on the actual port, while the other programs listens on some other port or address that the proxy-server connects to.
Using a proxy seems to be the way that WCF handles port-sharing. Quote from this link:
When a net.tcp binding enables port sharing (by setting portSharingEnabled=true on the transport binding element), it implicitly allows an external process (namely the SMSvcHost.exe, which hosts the Net.TCP Port Sharing Service) to manage the TCP socket on its behalf.

Some programmer dude
- 400,186
- 35
- 402
- 621
-
Is there a way to implement what WCF is doing in C++? Maybe use IIS or the OS itself to act as a proxy? – red.clover Dec 07 '11 at 08:04
-
1
-
@RemyLebeau-TeamB But it isn't clear (to me) what the proxy would do. Contact both servers? or just one? which one? at random? – curiousguy Dec 12 '11 at 00:13
-
The proxy needs to listen on an available port. When a client connects to the proxy port, the proxy then connects to IIS's port, and passes data back and forth between the two connections as needed until either the client or IIS disconnects, at which time the proxy then closes its endpoints for both connections. – Remy Lebeau Dec 12 '11 at 02:01