# For each connection we accept while (my $con = $lsock->accept) { # This holdes the Child PID I believe my $child; # Fork a kid or die baby die "Can't fork: $!\n" unless defined ($child = fork()); if ($child == 0) { # Close the child's listen socket, we don't need it $lsock->close if $lsock; ### # Here's the problem I believe. On while $line = <$con> # I'd like to do "last if no data recieved for $x seconds." ### # For each line of input from the connection while (my $line = <$con>) { # remove newlines, bad data, etc. $line = filter($line); unless ($line) { print $con $error; next } # I determine what to send back by what they send in if ($line eq 'QUIT' ) { print $con "+OK Sayonara\n"; last; } elsif ($line eq 'GET DATA') { print $con "+OK Sending DATA\n", $lib->get_data, "\n.\n"; next; } else { print $con $error; next } } # Close this connection $con->close if $con; exit(0); } else { # We're the parent, we've already handed the connection off $con->close; } }