HaB has asked for the wisdom of the Perl Monks concerning the following question:
my $server = create_socket($config{'port'}); my $sel = IO::Select->new($server); while(1) { # straight out of perldoc IO::Select [-; while(@ready = $sel->can_read(1)) { my ($new); foreach $client (@ready) { if($client == $server) { $new = $server->accept(); $sel->add($new); } else { $msg_total = 0; while(<$client>) { $message = $_; print "\'$message\'\n"; # for logging: my $msg_length = length($message); $msg_total++; serv_out("Processing $msg_length bytes from $remot +e_ip\n"); # split the message into segments # we are splitting on carriage returns (NOT newli +ne!) @segments = split /\015/, $message; # call a sub to loop over the segments process_segment(\@segments, $client); } # end while(<$client>); debug_out("Closing connection..."); } $sel->remove($client); $client->close(); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: is the socket done or not?
by tye (Sage) on Dec 04, 2000 at 23:07 UTC | |
|
Re: is the socket done or not?
by Fastolfe (Vicar) on Dec 05, 2000 at 05:33 UTC | |
|
Re: is the socket done or not?
by repson (Chaplain) on Dec 05, 2000 at 06:47 UTC | |
|
Re: is the socket done or not?
by merlyn (Sage) on Dec 05, 2000 at 02:54 UTC |