I have a strange problem. Trying to write a network app in python. Currently I am using osx and I have troubles with sockets. My code works fine on debian, but when I try to use recv(buff_size) on a connected tcp socket I get this error:
socket.error: [Errno 35] Resource temporarily unavailable
Add a comment
|
1 Answer
Are you using non-blocking sockets, or timeouts? According to this table, Errno 35 is EAGAIN on OSX; according to Apple man pages recv(2):
[
EAGAIN]The socket is marked non-blocking, and the receive operation would block, or a receive timeout had been set, and the timeout expired before data were received.
It could also be possible that socket.setdefaulttimeout was called with non-zero value (in which case socket.getdefaulttimeout would return non-none value.
See also Spurious recv() EAGAIN on OSX?; Blocking socket returns EAGAIN.
4 Comments
fulaphex
I didn't set sockets to be either blocking or non blocking. I thought they are blocking by default. When I have set it manually to blocking, it works.
fulaphex
But in an example, that I got from some tutorial I don't see setting socket to blocking and yet
recv() just blocks the socket till something comes to the socket.Antti Haapala
Yeah, I'd expect them to be blocking as well, but maybe something else is setting a default.
fulaphex
What confuses me most, is that on debian it is blocking by default, on mac sometimes it is blocking when You don't specify and sometimes not. Messy. But it teaches user, to always take care of everything and make sure, that everything is how he wants it to be