while ($client = $server->accept( )) { $clientCount = &add_Clientcount($clientCount); (adds 1) # fork off a child while (defined(my $data_recv = <$client>)) { # Do various things some of which depends on # the client count, one this is a disconnect on # a data string sent which then subtracts the # client from the total count $clientCount = $subt_Clientcount($clientCount); (subtracts 1) # There can be a kill, which will stop the listener # but only if on the disconnect the total number of # clients is 0, I don't want to kill it if a # client is still connected } }