Ah...I was hoping it could exit the while loop so I could start multiple servers over time. My expectation was the server may need to wait for clients, hence my use of the while here, but this was not working with close($client) since it just stayed in the loop.
Gave this a try and my working code now looks like:
sub server_run_single()
{
my ($server,$keepAlive,$i,$loop,$verbose) = @_;
my $d_count = 0;
my $result = 0;
print "Running Server loop $i of $loop.\n" if $verbose;
# accept and process connections
my $client = $server->accept( );
$clientCount = &add_Clientcount($verbose);
print "Connected - " . &id_client($client) . "\n";
while ( defined (my $data_recv = <$client>) )
{
if ($data_recv =~ m/discon/)
{
$clientCount = &subt_Clientcount($verbose);
# Get out of this loop
close($client);
}
print STDOUT $data_recv if $verbose;
print $client "You said - $data_recv\n" if $verbose;
}
print "Exiting loop $i of $loop.\n" if $verbose;
return $result;
}
Thanks!
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.