2008年10月2日 星期四

Socket experience

Server
socket
bind
listen
accept
close

Client
socket
connect
close

While client issue the connect, the physical packet sequence is like

1. SYN (client -> server)
2. SYN+ACK (server->client)
3. ACK

But I found that server will auto send the FIN wjile the client is trying to connect the server.
So the connection will closed immediately while the client is trying to connect the server.

4. FIN+ACK
5.ACK

Afterall the client will also send the FIN to close the connection.

6. FIN+ACK
7. ACK

The server will respond the error
Socket Error: Transport endpoint is not connected

When a program is terminated using the exit, it will send the reset to the connected socket.

沒有留言: