Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

(delete) UDP and IO::Socket

by toadi (Chaplain)
on Jan 15, 2002 at 16:00 UTC ( #138879=perlquestion: print w/replies, xml ) Need Help??
toadi has asked for the wisdom of the Perl Monks concerning the following question:

my client-script:
use strict; use IO::Socket; my ($host,$port) = ("localhost","9000"); my $remote = IO::Socket::INET->new( Proto => "udp", PeerAddr => $host, PeerPort => $port ) or log_die "cannot connect to $host - $port\n"; die("[Connected to $host:$port]\n"); syswrite($remote, "Yooo\n")
use strict; use IO::Socket; my $socket=IO::Socket::INET->new(LocalAddr => 'localhost', LocalPort => 9000, Proto => 'udp') or die "socket: $!"; my $length; while (defined($length=sysread($socket, my $buffer, 65536)) && $length + != 0) { die "sysread: $!" if (!defined($length)); # When I have a connect from a client start another very big script +:) system('./'); exit; }
So as you see when there's a connect from a client, I need to start another proces.

1) client -> server -> start ./sleep

2) client -> server -> ./sleep still running -> don't wait

3) client -> server -> ./sleep still running -> don't wait

4) client -> server -> sleep not running? start ./sleep

=> for these 2 the server will start sleep 2 times in a row after they are finshed. This I don't want, I want ./sleep only to start when client connects and there is no other sleep running.

For the moment my existing codes makes sure only one ./sleep process is running at a time(thanks to spawning a child and a wait() in the parent). In case 2 and 3 there should never run a ./sleep. only when there is a new connect when there is no ./sleep running.

My opinions may have changed,
but not the fact that I am right

Replies are listed 'Best First'.
Re: UDP and IO::Socket
by toadi (Chaplain) on Jan 15, 2002 at 16:17 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://138879]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-02-26 14:06 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (373 votes). Check out past polls.