sendto : Resource temporarily unavailable (errno 11)

后端 未结 2 1798
甜味超标
甜味超标 2021-01-06 01:45

I am having a problem with sendto.

I have a receiver who receives UPD packets with recvfrom and then replies to the sender using sendto.

Unfortunately, I am

2条回答
  •  梦毁少年i
    2021-01-06 02:06

    The error you are getting:

    EAGAIN or EWOULDBLOCK: The socket is marked nonblocking and the requested operation would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.

    You set the socket to non-blocking (O_NONBLOCK). The socket is still busy sending the previous message. You cannot send another until the first has finished sending. That's why sleeping helped.

    Don't set it to non-blocking, or try again after select says you can.

提交回复
热议问题