我IO::Socket::INET
用来创建这样的套接字:
$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";
Run Code Online (Sandbox Code Playgroud)
那么,我想读取和写入两个套接字的数据,所以序列是:
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.
Run Code Online (Sandbox Code Playgroud)
一切都很好,直到第5步:在服务器端后收到我的消息4并发回这应该是通过捕获MSG5 $line = <$lsn2>
,而不是捕获有意义的价值,它捕获所有0.我用wireshark看看发生了什么,在服务器发给我msg5之后发送了我身边的RST ACK.
服务器中的函数收到msg4并立即发送回msg5.如果我摆脱了该函数中msg4的发送,那么发送msg5之后的是FIN ACK
.
谁能告诉我为什么RST ACK
会这样?perl脚本可以打开两个套接字并像我一样读写.
归档时间: |
|
查看次数: |
1290 次 |
最近记录: |