Quote:> What happens if a TCP server binds its well known port, and a
> connection request is issued by a client between that time and the time
> the server begins listening? Will the client's connection request be
> refused, or will it be held until the server starts listening?
My first suggestion is "try it and see what happens". Just modify any
server by putting a sleep() between the bind() and listen(). Use telnet
to try and connect to the server (since you can telnet to any port number),
and watch what happens with a free tool such as tcpdump.
What you'll see is that the connection requests from the client are
ignored by the server, because the server hasn't called listen().
Most clients retransmit their SYNs a fixed number of times, so the
client should get through eventually.
By default all sockets are created "active" and with a state of CLOSED
(use netstat -a to see this). One part of listen() is to convert an
active socket into a passive socket, and you'll see the state change
to LISTEN with netstat. Only in the LISTEN state will an incoming SYN