1

I use nonblocking UNIX UDP socket to transfer data from one process to another:

audio_s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
audio_s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 5500000)
audio_s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 5500000)
audio_s.setblocking(0)
try:
    os.remove(SOCKET_PATH)
except FileNotFoundError as e:
    pass
audio_s.bind(SOCKET_PATH)

And I often send data to remote process:

audio_s.sendto(data, REMOTE_SOCKET_PATH)

But sometimes (very rare) I catch BlockingIOError: [Errno 11] Resource temporarily unavailable on sendto call. What reason can be for this? Resource temporarily unavailable looks like very generic sentence.

  1. Is it possible to know more detailed information? For example send buffer overflowed of remote receive buffer overflow? Are these possible reasones? or only 1 of them?
  2. Can I control current datagram count in send/receive buffer?
  3. What is correct way to process or avoid this situation?

If I remove line with:

audio_s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 5500000)

it works without this exception

Ivan Borshchov
  • 3,036
  • 5
  • 40
  • 62

1 Answers1

2

Errno 11 is EAGAIN, from 'man sendto':

[EAGAIN] The socket is marked non-blocking and the requested operation would block.

Good explanations are there: When a non-blocking send() only transfers partial data, can we assume it would return EWOULDBLOCK the next call? and there: EAGAIN Error: Using Berkeley Socket API

Community
  • 1
  • 1
Vadim Key
  • 1,242
  • 6
  • 15