Date: Tue, 23 Jul 2002 00:36:36 -0400
From: "Mike T. Machenry" <[EMAIL PROTECTED]>
What are the exact semantics of accept? I have an example program
taken from Advanced Perl Programming by Sriram Srinivasan.
use IO::Socket;
$sock = new IO::Socket (...);
die unless $sock;
while ($newsock = $sock->accept()) {
while (defined ($buf = <$newsock>)) {
print $buf;
}
}
close ($sock);
It is my understanding the accept() awaits a new connection from
a client and blocks until it is read. This is my experience with
running the program aswell. However this program leads me to
believe that accept is going to return a false value and fall
through to the close. If it is a blocking method that awaits a
connection, how could it possibly know that no connection is
comming and it should close($sock)?
"man accept" and presume that Perl follows the same semantics as the
C library. Essentially two cases: you marked the socket as nonblocking
so could get EWOULDBLOCK in $! (not applicable to the code sample above),
or there was a problem trying to listen on the socket (including signal
interrupts!).
--kag