Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: function to count pending packets in TCP socket
by salva (Canon) on Jan 31, 2018 at 10:38 UTC | |
by VinsWorldcom (Prior) on Jan 31, 2018 at 11:33 UTC | |
|
Re: function to count pending packets in TCP socket
by thanos1983 (Parson) on Jan 31, 2018 at 10:28 UTC | |
|
Re: function to count pending packets in TCP socket
by Anonymous Monk on Jan 31, 2018 at 18:08 UTC | |
|
Re: function to count pending packets in TCP socket
by Anonymous Monk on Feb 01, 2018 at 22:04 UTC | |
|
Re: function to count pending packets in TCP socket
by Anonymous Monk on Feb 09, 2018 at 06:56 UTC | |
by Anonymous Monk on Feb 09, 2018 at 13:13 UTC |