Re: Not getting an NSStreamEventHasBytesAvailable message
Re: Not getting an NSStreamEventHasBytesAvailable message
- Subject: Re: Not getting an NSStreamEventHasBytesAvailable message
- From: Jens Alfke <email@hidden>
- Date: Thu, 09 Feb 2017 20:34:28 -0800
I’m pretty sure you only get another NSStreamEventHasBytesAvailable event once you have processed all the data from the last event.
Hm. But then how do you process all the data without running the risk of blocking? The first read won’t block because you know there’s data, but if you then check hasBytesAvailable and keep issuing read calls, you run the risk that hasBytesAvailable will return a false positive, leaving you blocked. (The docs are pretty clear that it’s allowed to return YES even if it doesn’t know whether there are bytes or not.)
Also, the examples in Apple’s “Stream Programming Guide” only issue a single read call in response to a bytes-available event.
—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