2016-02-13 54 views
1

我有一个奇怪的问题。试图在python中编写一个网络应用程序。目前我正在使用osx,而且我有套接字问题。我的代码工作Debian的罚款,但是当我尝试对连接的TCP套接字使用recv(buff_size)我得到这个错误:
socket.error: [Errno 35] Resource temporarily unavailablePython插槽错误否35

回答

2

是否使用非阻塞套接字,或超时? According to this table,Errno 35在OSX上为EAGAIN;根据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.

这也可能是可能的socket.setdefaulttimeout被称为非零值(在这种情况下socket.getdefaulttimeout将返回非none值


Spurious recv() EAGAIN on OSX?见; Blocking socket returns EAGAIN

+0

我没有将套接字设置为阻塞或非阻塞,我认为它们在默认情况下是阻塞的,当我手动设置阻塞时,它可以工作 – fulaphex

+0

但是在一个示例中,我从一些教程中得到了我没有看到将套接字设置为阻塞,然而'recv()'只是阻塞套接字,直到有什么东西进入套接字。 – fulaphex

+0

是的,我希望他们也能被阻止,但也许别的什么是设置默认值。 –