Are NSStreams or the sockets they use buffered?
Are NSStreams or the sockets they use buffered?
- Subject: Are NSStreams or the sockets they use buffered?
- From: Ryan Homer <email@hidden>
- Date: Wed, 9 Jan 2008 12:02:33 -0500
I am using NSStream's getStreamsToHost:port:inputStream:outputStream:
and sending data over the outputStream to send a file to the receiving
client.
--- DETAILS ---
On my end, I implement my own buffering in case the packet of data
that I'm sending can't all be accepted by the recipient. However, if
another packet of data is "sent" but there is still data queued up,
I'm queue up this new data elsewhere and waiting for the send queue to
be emptied.
It may sound a little complicated, but the reason I'm doing it this
way is because the data is originally tagged with notification
information and only when the data is actually sent using
NSOutputStream's write:length: do I post the notification which will
let me know how much data has been sent thus far. So the backup queue
can hold the notification information, but the actual send queue is
just NSMutableData.
Anyway, even if you don't understand the above, the bottom line is
that I'm trying to send data with as small a buffer as possible so
that I'm sending data closer to real-time. This is because the
receiving client will not send any notification that it has received
the file until it has received the complete file.
--- END DETAILS ---
The end result at the moment is that on my side the file appears to be
completely sent way before the receiving end gets the complete file.
So I am wondering if the underlying socket connection that the Cocoa
framework uses is buffering my data.
Additionally, I am capturing NSStreamEventHasSpaceAvailable event
codes and I only send data based on this. So does this event code mean
that the socket can accept more data -- and possible not yet send it
so it'll buffer it --- OR does it mean that the receiving end of the
socket can really accept more data?
_______________________________________________
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