Hi everybody!
I have a code which is send hex data with tcp socket but sometimes when i cant creat a socket or i cant recv the socket my program is stuck it wont anymore i have to restart it! Who could i make my program to non blocking here is my sendig source
sub csillag_ki2
{
sleep($sleep_time);
local $sockx = new IO::Socket::INET (
PeerAddr => '192.168.0.11',
PeerPort => '2101',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sockx;
local @sebessegek=("\x1","\x2","\x3","\x4","\x5","\x6","\x7","\x8","\x9","\xa","\xb","\xc","\xd","\xe","\xf","\x10","\x11","\x12","\x13","\x14",);
local $bufx;
print $sockx "\xfe\xfd";
$sockx->recv($bufx,10000);
print "CSILLAG TILT START \n";
local $speedx=$kiir_seb->get();
local @beallitasx=("\x01","\x0d","\x38","\x2b","\x03","\x05","\x1b",@sebessegek[$speedx]);
local $hossz_bealx=@beallitasx;
#print $sock "\x01\x0d\x38\x2b\x03\x05\x1b\x0f\x0d";
local $CRC_x=@beallitasx[0];
for(local $ex1=1;$ex1<$hossz_bealx;$ex1++)
{
$CRC_x^=@beallitasx[$ex1];
}
#print $sockx @beallitasx;
#print $sockx $CRC_x;
print $sockx "\x05\x11\x19\x13\x04\x05\x1c\x0a\x09";
$sockx->recv($bufx,10000);
print $sockx "\x00\x06\x00\x0a\x0c";
$sockx->recv($bufx,10000);
print "PORT CLOSE \n";
close($sockx);
return;
}
I have a code which is send hex data with tcp socket but sometimes when i cant creat a socket or i cant recv the socket my program is stuck it wont anymore i have to restart it! Who could i make my program to non blocking here is my sendig source
sub csillag_ki2
{
sleep($sleep_time);
local $sockx = new IO::Socket::INET (
PeerAddr => '192.168.0.11',
PeerPort => '2101',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sockx;
local @sebessegek=("\x1","\x2","\x3","\x4","\x5","\x6","\x7","\x8","\x9","\xa","\xb","\xc","\xd","\xe","\xf","\x10","\x11","\x12","\x13","\x14",);
local $bufx;
print $sockx "\xfe\xfd";
$sockx->recv($bufx,10000);
print "CSILLAG TILT START \n";
local $speedx=$kiir_seb->get();
local @beallitasx=("\x01","\x0d","\x38","\x2b","\x03","\x05","\x1b",@sebessegek[$speedx]);
local $hossz_bealx=@beallitasx;
#print $sock "\x01\x0d\x38\x2b\x03\x05\x1b\x0f\x0d";
local $CRC_x=@beallitasx[0];
for(local $ex1=1;$ex1<$hossz_bealx;$ex1++)
{
$CRC_x^=@beallitasx[$ex1];
}
#print $sockx @beallitasx;
#print $sockx $CRC_x;
print $sockx "\x05\x11\x19\x13\x04\x05\x1c\x0a\x09";
$sockx->recv($bufx,10000);
print $sockx "\x00\x06\x00\x0a\x0c";
$sockx->recv($bufx,10000);
print "PORT CLOSE \n";
close($sockx);
return;
}