• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unexpected -readClosedForStreamTask: when remote socket closed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unexpected -readClosedForStreamTask: when remote socket closed


  • Subject: Unexpected -readClosedForStreamTask: when remote socket closed
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 20 Dec 2017 10:28:07 -0800

Another issue involving our usage of NSURLSessionStreamTask for a TCP client
connection. QE observes that, if the remote TCP server process is killed, the
-didCompleteWithError: delegate method is not called; instead
readClosedForStreamTask: is called. Since I’ve been unsure what the latter
method is for, my implementation just logs a message and does nothing. The end
result is that the app thinks the connection is still open even though it isn’t.

The docs for the method (below) seem to imply the socket is in a “half-open”
state, which seems incorrect in this case because the remote socket was closed
completely by the kernel on process exit.

In any case, what should I do in response to -readClosedForStreamTask:? Should
I call -readDataOfMinLength:…? Should I then wait for -didCompleteWithError: to
be called, or does it not get called at all in this situation?

/* Indiciates that the read side of a connection has been closed.  Any
 * outstanding reads complete, but future reads will immediately fail.
 * This may be sent even when no reads are in progress. However, when
 * this delegate message is received, there may still be bytes
 * available.  You only know that no more bytes are available when you
 * are able to read until EOF. */
- (void)URLSession:(NSURLSession *)session
readClosedForStreamTask:(NSURLSessionStreamTask *)streamTask;

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Getting EADDRNOTAVAIL when WiFi turned off, plus "nw_socket_output_finished" log
  • Previous by thread: Getting EADDRNOTAVAIL when WiFi turned off, plus "nw_socket_output_finished" log
  • Index(es):
    • Date
    • Thread