Saturday, April 30, 2005
Hansleman's List: Listener Processes & TCP Ports
More from Scott Hansleman's list of what great developers should know: "How many processes can listen on a single TCP/IP port?" One at a time. This was an interesting question for me, simply because I've not done any server-side TCP/IP programming in any language. I've experence with TCP/IP in Java writing to Oracle databases via JDBC. I also have some moderate Oracle DBA experience in installing and maintaining Oracle's listeners, plus I'd dealt with RCP over TCP/IP for communication between Java and C++ programs. All the same this topic got me into some good reading. I'd never had a good grip on exactly what sockets were and how they interracted with ports, simply because I'd never had to deal with them. Yes, yes, that's a pretty fundamental concept, but I was working in other areas. I found a great tech article in VS's help: Power Outlets in Action: Windows Sockets. The article has terrific descriptions of comms over named pipes and sockets, then talks about how comms over each are built up. Once again, the two guys at Sysinternals have a killer widget to help: TCPView. Note that my answer's "one at a time". I didn't find anything on this (didn't look), but I'd imagine one could have several processes sharing a port by queueing up requests and having a flag communicated between the processes to note when one process has freed up and unbound itself from the port, allowing the next process to bind to that port.