How to control reading socket without waiting

H

Hans

Hi,
I'm trying to write a udp client script, I already have:

my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $port,
Proto => $proto,
);
die "Could not create socket: $!\n" unless $sock;
my $do =1;
while $do {
print $sock "ping request from initiator,id is $i \n";
if ($line = <$sock>) {
print "receive: $line \n";
}
$i++;
sleep(1);
}


My problem is it will always wait to receive something before sending
next ping request. if no response from server, then it stops sending.

I hope it can keep sending no matter if there is response.

Anybody can help? thanks!


Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Can't connect to 'localhost' in IO::Socket 15
socket error 2
IO::Socket server 6
windows problem with socket write 2
problem with IO:Socket 2
problem to setup a socket 3
nat traverse 1
UDP receive 2

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top