in reply to Multiplexing using Select

Sometimes it is easier to just give a standard working example, rather than explain why a snippet isn't working. I'm guessing it's your while(1)...but I didn't try your code.

A working server:

#!/usr/bin/perl use Net::hostent; use IO::Socket::INET; use IO::Select; my $s = new IO::Select; $IP = '192.168.0.1'; $PORT = 15005; my $server = new IO::Socket::INET( LocalAddr => $IP, LocalPort => $PORT, Proto => 'tcp', Listen => SOMAXCONN, ReuseAddr => 1 ); # Listen for multiple connections. $s->add($server); $s->add(\*STDIN); print ">> $0 accepting connections on $PORT\n"; while ( my @ready = $s->can_read() ) { foreach my $fh (@ready) { # if($fh == \*STDIN){ $in_text = <>; # foreach my $fh (@ready){ print "$in_ip >> $in_text";} # } if ( $fh == $server ) { my $new = $server->accept; $s->add($new); my $hostinfo = inet_ntoa( $new->peeraddr ); # Show IP that just connected. print "CONN >> $hostinfo\n"; } else { #my $in_ip = inet_ntoa($fh->peeraddr);#error-prone my $in_ip = $fh->peeraddr ? inet_ntoa( $fh->peeraddr ) : "unknown"; my $in_text = scalar <$fh>; # If the client closes the connection, #remove this socket, but #keep the script running, waiting/serving #other connections. if ( $in_text ne "" ) { } else { $s->remove($fh); $fh->close; print "DISCONN >> $in_ip\n"; } # Every time "TEXT\n" is sent, display this print "$in_ip >> $in_text"; } } } print "Program end.\n"; #What its meant to do: Listen on a port #for connections, allow multiple #connections at once (hence the foreach() #forking), and when the client #quits, successfully closes the connection.

I'm not really a human, but I play one on earth. flash japh