while(1) { # loop for the parent # create a connection to incoming EC accept($EC, $SERVER); next if $pid = fork; # parent die "fork: $!" unless defined $pid; # failure #=================== Now, it's all about the child processes ==================# # the socket of the parent is no use to child close($SERVER); # my $new_sock = $sock->accept(); my( $select, @ok_to_read, @ok_to_write, $buf, $handle1, $handle2 ); $select = IO::Select->new(); $select->add($EC); while ($EC){ @ok_to_read = $select->can_read(1); foreach $handle1 (@ok_to_read){ $buf = <$EC>; if($buf){ print $buf; } } @ok_to_write = $select->can_write(1); foreach $handle2 (@ok_to_write){ print $handle2 "Hello from the SERVER new_sock\n"; } #sleep (1); } close($SERVER); } #$loop for the parent