in reply to Perl Sockets Problem
That will give you a loop until you manually kill the script. If you just want to receive one message then take out the $new_sock = $sock->accept() that's inside the while loop. If you want to keep the socket open for multiple messages, but also want to make sure the socket is cleanly closed (which my above example does not do). Write a SIG handler that makes sure the socket gets closed upon receiving a SIGHUP, SIGTERM, etc.my $new_sock = $sock->accept(); while (my $storage = <$new_sock>) { print $storage . "\n"; $new_sock = $sock->accept(); } close($sock);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl Sockets Problem
by JoeJaz (Monk) on Jul 10, 2003 at 15:57 UTC |