Simple UDP server
Tzury Bar Yochay
Afro.Systems at gmail.com
Wed Sep 10 14:40:22 EDT 2008
I am looking for the right way to write a small and simple UDP server.
I am wondering between Forking, Threading (found at SocketServer.py)
and the one describes at the snippet below.
Can you tell me the advantages and disadvantages of each
Would the one below will be capable of holding 30 concurrent
connections?
I have no intention of using Twisted or alike since I am looking for
making it as lightweight as possible
Thanks in advance,
Tzury Bar Yochay
# begin of snippet
from socket import *
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(('',50008))
while 1:
data,addr = UDPSock.recvfrom(4*1024)
if not data:
print "No data."
break
else:
print 'from:', addr, ' data:', data
UDPSock.close()
More information about the Python-list
mailing list