Close Socket Connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KaXo

    Close Socket Connection

    $r_socket = IO::Socket::INE T->new(
    PeerAddr => "10.0.26.78 ",
    PeerPort => 17990,
    Proto => 'tcp',
    Timeout => 1
    );
    ............... .......
    if ($r_socket && $r_socket->connected()) {
    close($r_socket );
    }

    after close($r_socket ), i use netstat -an to check the connecting list.
    i found "TCP 10.0.28.117:499 8 10.0.26.78:1799 0 TIME_WAIT"

    how to close the socket connection completely?
  • Jim Gibson

    #2
    Re: Close Socket Connection

    In article <80f2d4af.04031 01638.2b4edbe2@ posting.google. com>, KaXo
    <kaxo@sina.co m> wrote:
    [color=blue]
    > $r_socket = IO::Socket::INE T->new(
    > PeerAddr => "10.0.26.78 ",
    > PeerPort => 17990,
    > Proto => 'tcp',
    > Timeout => 1
    > );
    > ............... ......
    > if ($r_socket && $r_socket->connected()) {
    > close($r_socket );
    > }
    >
    > after close($r_socket ), i use netstat -an to check the connecting list.
    > i found "TCP 10.0.28.117:499 8 10.0.26.78:1799 0 TIME_WAIT"
    >
    > how to close the socket connection completely?[/color]

    The socket connection is kept open for 2-4 minutes to allow stray
    packets scattered all over the world-wide internet to find their way
    home. This is the "TIME_WAIT" state.

    You can try setting the ReusePort (or ReuseAddr?) attribute on the
    socket, which will allow you to reopen the socket sooner after you have
    closed it.

    FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.

    Comment

    Working...