I have an interesting problem with my socket testing application.
I installed a listening socket with the AcceptCallback function. I connected to the listening socket using:
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault,
(CFStringRef) self.clientService.hostName,
self.clientService.port,
&myReadStream,
&myWriteStream);
and I sent the data back to the listening socket myReadStream and myWriteStream, both of which I applied to their NSStream equivalents.
The problem occurs after sending many separate data packets. The size of the packets does not matter, this is the number of packets (or the number of CFStreamCreatePairWithSocketToHost creations) that appear to be causing an error.
After sending a ton of packets (maybe around 100 or 200), when I try to send data via NSOutputStream, I get an error in the NSStreamEvent callback:
Operation could not be completed. (NSUnknownErrorDomain error 8.)
Then, if I try to create a new service and publish it on the network, I get an error when I try to resolve the new address. This gives me error code 10 in NSNetService: delegate didNotResolve method (also here the error description is empty.)
It is almost as if the listening socket is “full”, but it seems to work fine, because when I check CFSocketIsValid, it returns true.
I am at a dead end and spent several hours trying to debug the situation ... Any thoughts on anyone? Thanks.
source
share