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)?

thanks for the help,
-mike

Reply via email to