Re: close() on tcp socket.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, April 6, 2011, ratheesh kannoth <ratheesh.ksz@xxxxxxxxx> wrote:
> connect() system call establishes a connection as shown in below steps.
>
> 1. Â |client | Â----------------- syn ---------------> Â| server |
>
> 2. Â|Server| Â--------------syn+ ack --------------> | client |
>
> 3. Â| Client | -----------------ack --------------------> | Server |
>
>
> But establishing connection , client calls close() system call. Client
> is sending FIN+ ACK to server Â[ i expected only FIN to be sent from
> client to server ]
>
> Is this a valid scenario.? Âwhat could be the problem ?
>
>
> -Ratheesh

The problem is that both sides can never coordinate to close the
connection. So TCP does the best it can. It notifies the other side
that the connection will be closed and start a timer. If the othet
side gets the FIN + ACK its send an ACK. When the sender gets the ACK
closes the connection. If the ACK doesnt arrive and the timer expires,
it just close the connection, the other side will eventually will
notice that the connection was closed so it will also close its side.
So you dont need a handshacking protocol. In fact you cant design a
robust protocol. This is a particular case of a more general problem
known as the two army problem [1]

[1] http://en.m.wikipedia.org/wiki/Two_Generals'_Problem

Hope it helps,
Javier

-- 
-----------------------------------------
Javier MartÃnez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat AutÃnoma de Barcelona
Barcelona, Spain
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux