in reply to IO::Socket/multiple connections related

In addition to the list of event frameworks kindly provided by tfoertsch, I would like to add my own IO::Lambda, which I really wish had more adoption and hope everyone else would excuse me for PRing. Anyways. If you feel like trying it, I'd be glad to provide help. Using it, your task would be written basically as such:
use strict; use IO::Socket; use IO::Lambda qw(:all); use IO::Lambda::Socket qw(:all); my $server = IO::Socket::INET-> new( Listen => 5, LocalPort => 10000, Blocking => 0, ReuseAddr => 1, ); die $! unless $server; lambda { context $server; accept { # socket with an incoming connection my $conn = shift; # tell the loop to accept() again again; unless ( ref($conn)) { warn "accept() error:$conn\n" unless ref($conn); return; } # now read all from the new connection context $conn; readable { my $buf; my $n = sysread( $conn, $buf, 65536); unless ( defined $n) { warn "error reading:$!\n"; } elsif ( $n == 0) { warn "connection closed\n"; } else { print $buf; again; } }} }-> wait;
Hope it helps