Dear Perl Monks
I want to monitor an open TCP connection on my client, as the server may have silently died or network connection is broken so I would continue to write data on my TCP socket until the send window will be 0 and eventually I may lose the data. Unfortunately the server speaks a very simple protocol without any application layer acks. It entirely relies on TCP doing the job. This I cannot change
In Linux there is a command 'ss' which gives some status information regarding socket connections. In particular it provides 'send-q' which is the count of sent TCP packets not yet acknowledged by the peer. Is there any way to get this information by a Perl function?
I would like to use it in the following way (just pseudo code)
my $conn = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, +Proto => 'tcp'); die unless ($conn); syswrite($conn, "message content"); doSomeOtherStuff(); #by now, under normal conditions, message should have reached the peer + and be acknowledged my $pendingMessages = send_q($conn); #this is the function I am lookin +g for but have not found yet if ($pendingMessages) { #perform some recovery actions here. Stop sending messages, until al +l previous messages have been acknowledged }
It would be so great, if someone could give me a hint how to do it. Thank you! Andreas
In reply to function to count pending packets in TCP socket by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |