I'm trying to get a simple 'listner' to work. Here is what I have; A host that is constantly sending text to another host on a particular port.

All I want to do is record (for now send to stdout) that data, AND here's the problem, be able to kill the listner at any time.

But when I kill the listner, the sending host stays in CLOSE_WAIT

anywhay here's my dumb little program ....

------------------------------------------------- #!/usr/bin/perl use IO::Socket; use IO::Select; sub sig_do { my $signame = shift; $got_usr1++; } $shucks = 0; $SIG{USR1} = \&sig_do; $local_port = 2282; $local = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$local_port, Listen=>"1" ) or die "Can't open socket\n"; # wait for connection and create a new handle $remote = $local->accept; while (<$remote>) { if($got_usr1) { last }; $data = $_; $peer_addr = $remote->peerhost; print "PEER:$peer_addr DATA:$data"; #play with data .... } printf "USR1 signal, now close the connection\n"; close $remote; close $local; -----------------------------------------------------
Am I trying to do something that can't be done ?

Thanks for any help ...

-pete

Edit kudra, 2002-08-19 Changed title


In reply to IO:socket client stays in CLOSE_WAIT after close (was: IO::Socket question from total newbie) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.