tags:

views:

32

answers:

1

I have a TCP server that creates a (blocking) socket, waits until it is available for reading using select(), then calls accept() and starts reading the data.
Here is an example (not mine) illustrating the concept.

The question is, at what points of TCP handshake does select() and accept() calls return?

TCP 3-way handshake

Ubuntu Hardy, if it matters.
2.6.31-14-server #48ya1 SMP Fri Apr 2 15:43:25 MSD 2010 x86_64 GNU/Linux

+1  A: 

The select() returns, indicating that the listening socket is "readable", immediately after the last packet in that diagram is recieved.

If you had blocked on accept() instead, it would have returned at that same point (when the server socket transitions to ESTABLISHED).

caf