I am using IO::Socket::INET
to create socket like this:
$lsn1 = IO::Socket::INET->new(
PeerAddr => '192.168.0.2',
PeerPort => 1850,
Proto => 'tcp',
Type => SOCK_STREAM
) || die "Can't connect to 192.168.0.2:1850 : $!\n";
$lsn2 = IO::Socket::INET->new(
PeerAddr => '192.168.0.2',
PeerPort = >1852,
Proto => 'tcp',
Type => SOCK_STREAM
) || die "Can't connect to 192.168.0.2:1852 : $!\n";
then, I want to read and write data to both sockets, so the sequence is:
1. $lsn1->print(msg1); send message 1 to server from $lsn1.
2. $line = <$lsn2>; receive message 2 from server from $lsn2.
3. $lsn2->print(msg3); send message 3 to server from $lsn2.
4. $lsn2->print(msg4); send message 4 to server from $lsn2.
5. $line = <$lsn2>; receive message 5 from server. But it is all zeros! However I can
see the data on wireshark.
everything is fine until step 5. After the server side receive my message4 and send back
msg5 which is supposed to be capture by $line = <$lsn2>
, instead of capture meaningful value it capture all 0s'. I used wireshark to see what happened, a RST ACK from my side was send after the server send me msg5.
A function in server received msg4 and send back msg5 immediately. If I get rid of the sending of msg4 in that function, what follows the sending of msg5 is FIN ACK
.
Can anyone tell me why RST ACK
is happening? Can a perl script opens up two sockets and read and write like I did.