Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-23 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found