perlquestion
HaB
Hrm... <br><br>
I have been poking at this one all morning, and I can't seem to figure this one out. I have a little server app that recieves data from a corresponding client app. The problem is, the server can't seem to figure out when the client is thru sending data. The spec on the project is that the server close and regenerate the socket after each client is finished sending data, but it never happens. The client sends, and the server just sits. I have tried every method/module I can think of. Here is the latest incarnation using IO::Select. <br><br>
Caveat: This is under Win32, which I am new to developing under. Not sure if that matters or not.<br><br>
<code>
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 $remote_ip\n");
# split the message into segments
# we are splitting on carriage returns (NOT newline!)
@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();
}
}
}
</code>
<br><br>
Any ideas? <br><br><br>
-HaB<br><br><br>
hword.