What can cause a “Resource temporarily unavailable” on sock send() command

后端 未结 3 1140
南笙
南笙 2020-12-02 12:01

What can cause a Resource temporarily unavailable error on a socket send() command? The socket is setup as AF_UNIX, SOCK_STREAM. It wo

3条回答
  •  独厮守ぢ
    2020-12-02 12:38

    That's because you're using a non-blocking socket and the output buffer is full.

    From the send() man page

       When the message does not fit into  the  send  buffer  of  the  socket,
       send() normally blocks, unless the socket has been placed in non-block-
       ing I/O mode.  In non-blocking mode it  would  return  EAGAIN  in  this
       case.  
    

    EAGAIN is the error code tied to "Resource temporarily unavailable"

    Consider using select() to get a better control of this behaviours

提交回复
热议问题