Find the answer to your Linux question:
Results 1 to 3 of 3
Hi ! In my program I close all TCP sockets before exiting it. But nevertheless remain the sockets in TIME_WAIT state for a while. ('netstat -na' shows me that.) What ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Posts
    1

    Program completed but TCP sockets remain for a while


    Hi !

    In my program I close all TCP sockets before exiting it.
    But nevertheless remain the sockets in TIME_WAIT state for a while.
    ('netstat -na' shows me that.)

    What I want is to ensure that all my TCP sockets get removed
    from the system immediately when I stop my process.

    Is it possible and how?

  2. #2
    Just Joined!
    Join Date
    Dec 2005
    Posts
    2
    I can be wrong, but I think, After close connection command executed, Linux OS can't close connection immediately, it must take a short time to close, that is reason when typing 'netstat -na' you saw TIME_WAIT state.

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Location
    Romania
    Posts
    42
    The close of socket goes through the TIME_WAIT state. The duration of TIME_WAIT state is twice the maximum segment lifetime (MSL is the maximum amount of time that any given IP datagram can stay in a network). The recommended value of MSL (RFC 1122) is 2 minutes, but Berkeley implementations use 30 seconds. So, the duration of the TIME_WAIT is between 1 and 4 minutes. But in fact you have to take also into consideration the IPv4 TTL field with a maximum value of 255.

  4. $spacer_open
    $spacer_close

Posting Permissions

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