Simple UDP server



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()
.



Relevant Pages

  • Re: Simple UDP server
    ... Tzury Bar Yochay wrote: ... I am wondering between Forking, Threading ... and the one describes at the snippet below. ...
    (comp.lang.python)
  • Re: UDP performance.
    ... issue - it has traditionally been the source of statements like "FreeBSD's threading implementation is weak/bad/broken". ... And these days ISC can't consciously recommend FreeBSD for use on high-traffic DNS servers because UDP performance has gone downhill since 5.x. ... Dinesh> affect voip applications/servers such as asterisk when run on ... One of the problems ISC diagnosed had to do with the highly unusual workload pattern of UDP: many different threads simultaneously sending using a single socket leading to unnecessary socket buffer contention. ...
    (freebsd-performance)
  • How Can I DeviceIoControl in less than 10 milliseconds?
    ... The following is code snippet inside a thread that first waits on an ... &numBytesRead, ... socket handling) *sometimes* takes MUCH longer than 10 milliseconds... ... the way I have been using overlapped I/O as depicted above gives ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Multi-threading with multi-port server
    ... Can I ask your guidance on how to imeplement server with multi- ... threading and multi-port? ... If you use asynchronous sockets then all socket calls return quickly and you can run several sockets concurrently in the main thread. ...
    (microsoft.public.vc.mfc)
  • Re: socket setdefaulttimeout
    ... > I'm doing DNS lookups it is important to make sure> that the socket doesn't just hang there waiting for a response. ... > could take advantage of the setdefaulttimeout in the socket module, to> limit the amount of time the sockets take for a lookup. ... Still gethostbyname and its brethren can be a pain for single- threaded event-driven programs, because they can block for significant time. ... Under some older threading systems, ...
    (comp.lang.python)