in reply to Re: Getting Client to Disconnect
in thread Getting Client to Disconnect

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!