开发者

TCP handshake phases corresponding to select() and accept() return points

开发者 https://www.devze.com 2023-01-17 00:49 出处:网络
I have a TCP server that creates a (blocking) socket, waits until it is available for reading using select(), then calls accept() and开发者_如何学Go starts reading the data.

I have a TCP server that creates a (blocking) socket, waits until it is available for reading using select(), then calls accept() and开发者_如何学Go 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 handshake phases corresponding to select() and accept() return points

Ubuntu Hardy, if it matters.

2.6.31-14-server #48ya1 SMP Fri Apr 2 15:43:25 MSD 2010 x86_64 GNU/Linux


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消