While writing onto NSStream
Should i Rely on
'hasSpaceAvailable
' method or the event in the 'handle:event' method
'NSStreamEventHasSpaceAvailable
'
Or Should i check 'hasSpaceAvailable
' if not available, i have to retry after a particular
amount of time or should i wait till the delegate event to call till i begin to write?
As of now its working when i use hasSpaceAvailable and retry after some time dont know if its the right practice.
Any Help would be of much great.
When you're about to send first piece of data use hasSpaceAvailable
to determine whether stream is ready.
After sending some data you'll be getting stream:handleEvent:
method called and there you should check if NSStreamEvent
var is equal to NSStreamEventHasSpaceAvailable
; then you can write more data to the stream, otherwise something is wrong or stream is full.