Python packages recvfrom () queues?

It seemed to me that recvfrom () gave you the next packet on the IP address that it is listening on, and if it does not skip listening packets. We have a problem where the problem may be related to packages for recvfrom (), so it listens and captures all packages, even if recvfrom () is not actively listening.

I could not find the final documentation on this. Does anyone know for sure that the characteristics of recvfrom () are not packet queues when they are not called?

Code example

:

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) mcast_g = socket.inet_aton(group) mreq = struct.pack('4sL', mcast_g, socket.INADDR_ANY) s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) s.bind(('', port)) while True: data, sender = s.recvfrom(1500) # Do stuff # Are packets being queued up here? 
+4
source share
2 answers

The kernel has a socket receive buffer. recv() and friends read from the buffer or block while it is empty. If you do not read fast enough, the buffer is full, and the UDP datagrams that come after the buffer is full are deleted. You can change the buffer size using the socket option SO_RCVBUFSIZE.

+4
source

It depends on the OS implementation, but on most modern OSs there is an amount of buffering.

0
source

Source: https://habr.com/ru/post/1488141/


All Articles