Mason Loring Bliss wrote: > On Tue, Aug 23, 2005 at 11:10:58AM -0400, Mason Loring Bliss wrote: > >> Hi, all! I'm learning about dealing with sockets in Perl, and I've >> got a question about some unexpected behaviour exhibited by the >> following test script. >> >> In the case where I open a connection and then close it before >> $socket->accept() is called, I'd expect $socket->accept() to return >> undef, but it never does. Will someone kindly tell me why this is? >> >> Thanks in advance! > > Is there a forum other than this one where I might ask this question? > I was hoping that maybe someone here knew the answer and would share > it... > > Should $socket->accept() return undef if the client in question has > died off before the server has gotten around to accepting() the > connection? Maybe my assumption is faulty, and there's no implicit > close happening when the initiating process dies. I'll explore this > possibility. > > Hm. No. When the client calls shutdown(2) or close() before the server > calls accept(), the server's $socket->accept still returns with a > socket, and not undef. > > Am I missing something fundamental here? Is this a bug in IO::Socket? > Is there some other issue of which I'm unaware?
I don't think there's any problem with IO::Socket. Even if accept returns a socket, you should receive an EOF on that socket when you try to read from it, which tells you that the peer has closed the connection. I think you just need to check for both situations: an error from accept(), and EOF from read(). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>