Most likely it has been closed by the peer already. (From a pure logic point of view, it is also possible that your file descriptor is a bad one anyway, due to other programming errors)

Following piece of code demos this situation:
use strict; use IO::Socket; use threads; $| = 1; threads->create(\&server); my $socket = IO::Socket::INET->new(Proto => "tcp", PeerAddr => "localh +ost", PeerPort => 7001) || print "Socket creation error: $!\n"; sleep(5); print "about to close socket on client side\n"; close($socket); print "closed socket on client side\n"; print $!; sub server { my $server = new IO::Socket::INET(Proto => "tcp", LocalPort => 700 +1, Listen => 5) || die "failed to establish socket\n"; my $client = $server->accept; sleep(1); print "about to close socket on server side\n"; close($client); print "closed socket on server side\n"; }

In reply to Re: Re: •Re: A non-forking server model with issues closing sockets on users by pg
in thread A non-forking server model with issues closing sockets on users by JPaul

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.