What I'm trying to do is send a string to my UDP server and receive some data back, but more than just once.
I'm relatively new to Perl so if this out of order in some way, please let me know...
But what's happening is: Like this, the second recv() fails. If I swap them and call for the other first, the second one still fails...
Long to short: Is there a better (or more correct) way to use the same connection to send and receive multiple times?
Code:
my $sock = IO::Socket::INET->new(Proto =>'udp',
PeerHost =>$host,
PeerPort =>$port,
Reuse => 1) or die $@;
$sock->send($status) or die "send() failed: $:\n";
$sock->recv($data,2000) or die "recv() failed: $:\n";
[BLOCK OF CODE FOR $DATA]
$sock->send($mpr) or die "send() failed: $:\n";
$sock->recv($data2,6000) or die "recv() failed: $:\n";
[BLOCK OF CODE FOR $DATA2]
I'm relatively new to Perl so if this out of order in some way, please let me know...
But what's happening is: Like this, the second recv() fails. If I swap them and call for the other first, the second one still fails...
Long to short: Is there a better (or more correct) way to use the same connection to send and receive multiple times?