问题描述
什么会导致套接字 send()
命令上的 Resource 暂时不可用
错误?套接字设置为AF_UNIX, SOCK_STREAM
.它大部分时间都有效,但偶尔会出现此错误.套接字的接收端似乎工作正常.
What can cause a Resource temporarily unavailable
error on a socket send()
command? The socket is setup as AF_UNIX, SOCK_STREAM
. It works most of the time, but occasionally gets this error. The receiving end of the socket appears to be working properly.
我知道这不是很详细,但我只是在寻找一般性的想法.谢谢!
I know this isn't very detailed, but I'm just looking for general ideas. Thanks!
推荐答案
"Resource暂时不可用"
是EAGAIN
对应的错误信息,表示操作将已阻塞但请求了非阻塞操作.对于 send()
,这可能是由于:
"Resource temporarily unavailable"
is the error message corresponding to EAGAIN
, which means that the operation would have blocked but nonblocking operation was requested. For send()
, that could be due to any of:
- 使用
fcntl()
显式地将文件描述符标记为非阻塞;或 - 将
MSG_DONTWAIT
标志传递给send()
;或 - 使用
SO_SNDTIMEO
套接字选项设置发送超时.
- explicitly marking the file descriptor as nonblocking with
fcntl()
; or - passing the
MSG_DONTWAIT
flag tosend()
; or - setting a send timeout with the
SO_SNDTIMEO
socket option.
这篇关于什么会导致 sock send() 命令出现“资源暂时不可用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!