I'm trying to wrap my head around the logic behind hasSpaceAvailable
on NSOutputStream.
In my app, I'm sending large amounts of data (100MB) broken up into 4080byte chunks (hard limit) over a CFSocket managed by NSInput/output streams.
When I start writing the data, about a quarter way through hasSpaceAvailable
suddenly becomes NO
, and so I add the data to a queue. However, if I ignore that and try to write the data anyways, the write seems to work as the return value of write:maxLength:
matches the maxLength parameter (4080).
What does the output stream have space for? As far as I can tell, when using UNIX/Berkley sockets there is no logic available to determine if the socket can be written to, you just write and determine if all of the data was written.
The documentation for the property states:
A boolean value that indicates whether the receiver can be written to. (read-only)
YES
if the receiver can be written to or if a write must be attempted in order to determine if space is available,NO
otherwise.
In my example where I'm seeing a NO, what factor is causing this result when I can still write to that socket.