Use epoll but still lose packet

lampahome pahome.chen at mirlab.org
Wed Nov 20 05:51:31 EST 2019


I use epoll to listen events to receive packet from remote client via tcp
socket

And I found it still lose packet from remote client when client sends 128
messages to me.

Is there any tips to avoid this? thx

I only use a while loop to catch events like below:
import select, socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind()
sock.listen(10)
epoll = select.epoll()
epoll.register(sock.fileno(), select.EPOLLIN)
while True:
 events = epoll.poll(10) # timeout=10 sec
 if not events:
  continue

 for fd,event in events:
  if event & select.EPOLLIN:
    sock.recv(1024)
...


More information about the Python-list mailing list