On Nov 21, 1:56 pm, David Goodenough <
dav...@kixeye.com> wrote:
> Is it true that a server which is listening for connections does not
> send the SYN,ACK packet back to a client until after the application
> actually calls accept(sock, addr, addrlen); ?
Theoretically, an implementation could do it either way. However,
every real-world implementation, by default, does not wait for you to
call 'accept' before it sends the SYN/ACK. This would needlessly
delays TCP session setup time and harm the platform's benchmark
scores.
The closest to an exception is Windows. Windows has a special accept
function in addition to the regular 'accept' function called
'WSAAccept'. You call this *before* even the SYN arrives to 'prime'
the accept. You can specify a pointer to a function you provide that
Windows will call to decide whether to send the SYN/ACK (and also set
QoS parameters and do other stuff).
http://msdn.microsoft.com/en-us/library/windows/desktop/ms741513%28v=vs.85%29.aspx
There is a performance hit associated with using this function.
DS