#!/usr/bin/perl -w use strict; use IO::Select; use IO::Socket; my $sock1 = new IO::Socket::INET(Listen => 1, LocalPort => 1234); my $sock2 = new IO::Socket::INET(Listen => 1, LocalPort => 1235); my $select = new IO::Select; $select->add($sock1); $select->add($sock2); while(my @ready = $select->can_read) { foreach my $fh (@ready) { if($fh == $sock1) { &fork_and_handle_sock1(); } elsif($fh == $sock2) { &fork_and_handle_sock2(); } } } sub fork_and_handle_sock1 { print "sock1\n"; } sub fork_and_handle_sock2 { print "sock2\n"; }
| We're not surrounded, we're in a target-rich environment! |
|---|
In reply to Re: Listening on 2 Sockets
by jasonk
in thread Listening on 2 Sockets
by DBordello
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |