§ä´m¦Û¤vª�...@¤ù¤Ñ <command....@alexbbs.twbbs.org> wrote: > I got a problem about UDP. > > How do I get the UDP buffer size? > > When the server had some delay in handling incoming UDP, it will lost > some package. I wonder it's because the system buffer size, is there any > ways to find the exactly size of the buffer? > > ex: > > client.py > import socket > > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > for i in xrange(1000): > s.sendto('xxx', ('192.168.1.135',10000)) > > > > server.py: in ip (192.168.1.135) > import socket > import time > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > s.bind(('',10000)) > time.sleep(10) > > # here will only recv 255 package, others are lost... > for i in xrange(1000): > msg, addr = s.recvfrom(500) > print i
I think you want setsockopt... >>> import socket >>> import time >>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) >>> s.bind(('',10000)) >>> s.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) 112640 >>> s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1048576) >>> s.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) 262142 >>> I ran the above on linux and I expect the limit 262144 is settable in /proc/sys/net somewhere. No idea whether the above works on windows! -- Nick Craig-Wood <n...@craig-wood.com> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list