Jeremy,

Are you running in a multi threaded environment?

bsd socket calls return the number of read or written bytes or -1 in case of 
error and if that happens errno is set.
And errno is different if your app is mutlithreaded or not as every thread 
needs its own errno. So historically it was a int but now its a macro to get it 
from the thread specific memory so your thread gets your "private" thread errno.

When you set the socket to non blocking or blocking yourself, then it stays in 
this mode until you change it. However certain things can occur while you sit 
in a wait call (poll/ select etc) which can make the call return early (EAGAIN 
for example) which means you have to be prepared for this and maybe have a loop 
to wait until you have enough data. Also in the case of TCP, your data might be 
chunked up in the middle. You can never assume one line is sent as a whole, it 
can arrive in pieces.

I dont think anything has really changed between 10.8 to 10.12 in this area.




Andreas Fink
------------------------------------------------------------------
Author of ulib networking library


> On 28 Oct 2016, at 00:15, Jeremy Thompson <jer...@warehousesports.com> wrote:
> 
> I have a strange problem that has showed up in OS X 10.11 and 10.12.  My 
> application is still using carbon libraries but all network communication is 
> done through BSD sockets.  When running the application on 10.11 in debug 
> mode certain times the read() call will return with this error Resource 
> temporarily unavailable.  I could see this happening if the socket was in 
> non-blocking mode but it is supposed to block.  The resource temporarily 
> unavailable error comes from perror.  I tried getting the error from the 
> socket with getsockopt and it returns an undefined error: 0.  To make this a 
> little bit more strange if I run this application in release mode none of 
> this comes up.  However, now in 10.12 i get this error in both debug and 
> release mode.  I first thought this may be a problem on the server side but 
> it sends back correct data on a wireshark capture.  I’m pretty sure its 
> locked down to the client application.  If I didn’t know better I would say 
> that the socket is somehow getting set to non-blocking but I can’t prove it.  
> This problem is nonexistent on 10.9 but I am unsure about 10.10 as I never 
> debugged the code on that version.  Any info would be greatly appreciated.
> 
> Thanks,
> Jeremy
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/macnetworkprog/afink%40list.fink.org
> 
> This email sent to af...@list.fink.org

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to