foreach $client ($select->can_read(1)) { if($serversocks{$client}) { # Activity on the listening socket means we have a new # client attempting to connect. # Get ahold of the new socket, assign it to all the whatnot, etc $client = $client->accept; $select->add($client); &setnonblocking($client); # <--- SEE HERE $connections{$client} = Connection->new($client, \%outbuffer, $Utils::thisserver); $unfinished{$client} = $connections{$client}; } #### sub setnonblocking { my $sock = shift; # Get the current state of the socket.. my $flags = fcntl($sock, F_GETFL, 0) or die "Can't get the flags on socket: $!\n"; # ..and then add O_NONBLOCK (nonblocking-ness) on to it. fcntl($sock, F_SETFL, $flags | O_NONBLOCK) or die "Can't set socket non-blocking: $!\n"; }