I have no real way to determine when the data is finished being read, other than there is nothing else coming in. Basically, I want to read the data from the client, act on it and return the results to the client and then have the server terminate the connection. (Using sysread in this example, because according to "Network Programming with Perl, page 359" it is the safest option with a nonblocking socket)
I've modified the code in the following way:
($client, my $client_addr) = $server->accept( );
my $result = fcntl($client, F_SETFL, O_NONBLOCK);
my $read = "";
my $buffer;
print "DEBUG Point: 1\n";
while (sysread($client,$buffer,1024)) {
print "DEBUG Point: 2\n";
$read .= $buffer;
}
print "DEBUG Point: 3\n";
print "$read\n";
This is a step closer. It exits the loop and prints the data ($read) to the terminal window.
Problem is, i am no longer seeing all of the data. With the original code from the first post I saw all of the data. The only problem was that it was not leaving the while loop after reading all of the data in. Now it seems to be leaving off the last few lines (i'm sending 14 lines of text through and only seeing 9 being printed to the terminal) | [reply] [d/l] |
| [reply] |