There are just too many unknowns in the OP's question for me to be of more help!
Some code would go a long way towards clarifying things!
I think we can both agree upon that!

Network Programming in C is a full 4 hour college level class. So this is not an "its easy, learn it over the weekend subject".

Getting this stuff to work "most of time" is not that hard. The complicated parts all involve these "yeah, but", "what happens if," situations. Perl is a bit different than the C functions.

Without some code, I can't tell what the OP is actually doing.

I looked back and found a Perl version of one my C client readn() routines that reads fixed length packets. Getting a zero byte return is not necessarily an error.

Getting a -1 in C or undef in Perl is an error. My C version just returned the -1 error. Here I sent the USR1 signal to myself just for grins to play around with it. I didn't keep my test report, so I can't prove that this works without some re-testing and having to post much more code. There could very likely be a "hole" in it.

It is completely possible for the "writer" to have already died while stuff is still available for the "reader" to read. I'm not at all sure what this "reset from the server" means - how the client is supposed to learn that and what it is supposed to once it does.

There are various ways to do the reads: blocking/non-blocking and flavors thereof.

sub readn { my ($socket, $bytes ) = @_; my $offset = 0; my $buf = ""; while ($offset < $bytes) { my $nread; my $nleft = $bytes-$offset; $nread = sysread($socket,$buf,$nleft,$offset); ## undef is like the -1 C return kill 'USR1',$$ unless (defined $nread); last if ($nread ==0); ## EOF $offset += $nread; } return $buf; }

In reply to Re^4: How to monitor TCP Resets using Sockets by Marshall
in thread How to monitor TCP Resets using Sockets by w3ntp

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.