Perl use IO::Select; use IO::Socket;

3 views
Skip to first unread message

netkiller

unread,
Sep 29, 2008, 8:48:40 AM9/29/08
to netkiller
use IO::Select;
use IO::Socket;

$lsn = new IO::Socket::INET(Listen => 1, LocalPort => 8080);
$sel = new IO::Select( $lsn );

while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if($fh == $lsn) {
# Create a new socket
$new = $lsn->accept;
$sel->add($new);
}
else {
# Process socket

# Maybe we have finished with the socket
$sel->remove($fh);
$fh->close;
}
}
}
Reply all
Reply to author
Forward
0 new messages