Visual C++ Network: How does a TCP connection close?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Visual C++ Network: How does a TCP connection close?

  1. #1
    Join Date
    Feb 2003
    Location
    Bangalore, India
    Posts
    1,354

    Visual C++ Network: How does a TCP connection close?

    Q: How does a TCP connection close?

    A: It takes three packets to start a connection, but it takes four to close it. As with the connection establishment, termination is also two-way. But the difference is, each closure is independent of the other. Once the connection is closed one way, the connection is then said to be half open. Now lets see how the termination sequence is.

    When one end decides there is nothing more to send, it sends a 'FIN' packet (a packet with 'FIN' flag on) to the other end. The other end sends an acknowledgement packet ('ACK') for the 'FIN' it received. Once this happens, one way is closed, and the connection is now half open. The other end meanwhile sends all the data if any, and when it is over it sends a FIN packet and this packet is acknowledged. Now the connection is effectively closed and no communication can take place between the end points.

    It would be better to note that, the end that initiates termination first is said to be performing an active close, while the other end, a passive close. However, it is possible to close simultaneously i.e performing a close without getting the 'FIN' from the other end. In such case both ends are said to be doing an active closure.

    Note: A 'FIN' packet is send when the application calls 'closesocket()' or 'shutdown()'.


    Last edited by Andreas Masur; November 13th, 2005 at 07:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center