Hrm...
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.
Caveat: This is under Win32, which I am new to developing under. Not sure if that matters or not.
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();
}
}
}
Any ideas?
-HaB
hword.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.