• 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
Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInputStream created from NSData - expected it to close at end of data, did not happen


  • Subject: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 10 Jun 2011 12:19:52 -0700

On Jun 10, 2011, at 11:39 AM, email@hidden wrote:

> 1. There an NSStream event "NSStreamEventEndEncountered". I would have expected to be sent this event when the Stream created from a piece of data reaches the end of that data. But okay, you said that one has to close the stream oneself. So I did that when the data input stream ![stream hasBytesAvailable] after having had bytes available. I then close the stream.

Those two things are not the same. That may be causing your trouble.
The hasBytesAvailable property tells you whether there is data available to read *right now*. It will return false if you’ve read all the bytes that have arrived, and no more have arrived yet.
NSStreamEventEndEncountered is posted when the EOF is reached. For a socket, that means that the other peer closed the connection.

Have you looked at the CocoaEcho sample code? It demonstrates how to do a simple TCP client and server. (Part of the MYNetwork code was originally adapted from it.)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
      • From: email@hidden
References: 
 >NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: Jens Alfke <email@hidden>)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)

  • Prev by Date: changing file name when copying a file in the same directory
  • Next by Date: Re: changing file name when copying a file in the same directory
  • Previous by thread: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Next by thread: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Index(es):
    • Date
    • Thread