#this sets up $main_sock to handle multiple connections...??? $readable_handles = new IO::Select(); $readable_handles->add($main_sock); #this returns an array of readable (and writeable) #handles/connections...??? $new_readable) = IO::Select->select($readable_handles, undef, undef+, 0); #So now I can iterate through this array just like I would #for any other, except it is an array of "connections"... foreach $sock (@$new_readable) { #in the case that ($sock == $main_sock) this means that #I need to listen for & add any new connections to the #list of $readable_handles, but why not to $new_readable #as well...??? if ($sock == $main_sock) { $new_sock = $sock->accept(); $readable_handles->add($new_sock); } else { $buf = <$sock>; if ($buf) { #does the line $readable_handles->can_write() mean that #these handles are not bidirectional...??? print "$buf\n"; my @sockets = $readable_handles->can_write(); #print $sock "You sent $buf\n"; foreach my $sck(@sockets){print $sck "$buf\n";} } else { $readable_handles->remove($sock); close($sock); } } }