Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

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

Have the server use shutdown to make the closing of the connection be more explicit to the clients.

I consider it a bug or design flaw that some TCP network stacks don't appear to do the equivalent of shutdown when a socket is closed, which means that the client won't know about the closure until it tries to send more data and waits a short while for the reply to that data to show up and tell it that the connection is no longer valid.

Updates:

See also (tye)Re: shutdown vs. close on INET sockets.

If you don't have control over the server, then you can change your test to have the client:

  1. Open the socket to the server
  2. Wait 10 seconds while you stop the service
  3. Write to the socket hoping for failure
  4. If no failure, wait 10 more seconds
  5. Write to the socket again

It shouldn't take very long for the response to a write to a closed socket to make it back to the client. However, if you shut off the server computer or break the network connection to it, then it may take 8 minutes before the client is willing to give up on the server.

- tye        


In reply to Re^3: syswrite and closed sockets (shutdown) by tye
in thread syswrite and closed sockets by InfiniteLoop

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.