Errno: 11, Resource Temporarily Unavailable

后端 未结 2 707
时光说笑
时光说笑 2021-02-05 14:36

I am using c sockets to implement a reliable UDP protocol. I am using the following code to set a timeout on a socket in which I\'m waiting for an acknowledgement. I am not su

2条回答
  •  死守一世寂寞
    2021-02-05 14:42

    When calling recvfrom() on a blocking socket and a time out had been set using setsockopt() it is normal to get the error EAGAIN (11) in case the call to recvfrom() timed out (that is: no data was received in the time period specified as time out).

    Verbatim from man recvfrom:

    RETURN VALUE

    ...

    ERRORS

    ... .

    EAGAIN or EWOULDBLOCK 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 was received. ...

    To get around this: Just call recvfrom () again ... ;-)

提交回复
热议问题