jewee
asked on
Using block - Perl...help!
Here is part of my script:
How do I modify the socket to make it nonblocking? What happens is that it hangs(waits) for a period of time!
my $socket = new IO::Socket::INET (
PeerAddr => '10.0.0.5',
PeerPort => '2222',
Proto => 'tcp',
);
@requestBytes=( 0xD0, 0x00, 0x00, 0x00,
0x28, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x65, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00 );
#print "@requestBytes\n";
$requestMsg = pack 'C*',@requestBytes;
$socket->write($requestMsg
while($socket->connected) {
$buffer=0;
#Retrieve only header
$socket->read($buffer,40);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you can continue and accept the fact that the data is not there then why are you asking for it.
If you want to "time out" then I would sue an alarm() to set a timeout and go on even if the request does not finish in the time required.