Can multiple apps listen for TCP on the same port?
Yuri
yuri at rawbw.com
Mon Dec 1 12:23:56 UTC 2014
I have a simple 'nc' based TCP server with shell script serving http
protocol. But when I run the second instance, it never gets any
connections and never fails.
'nc -l PORT' first calls listen with backlog=1 and socket option
SO_REUSEADDR, and then calls accept. Once client is accepted, it closes
the listening socket and only works with this connection.
Why the second nc instance still never accepts any connections, once the
first connection is accepted, and first listening socket is closed?
When one listening socket is closed, shouldn't other listening sockets
on the same port be accepting connections? It looks like the whole port
is blocked without even having the listening socket on it by one alive
connection (which after it was accepted doesn't have much to do with the
original port).
Yuri
More information about the freebsd-net
mailing list