Simple UDP server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tzury Bar Yochay

    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.recvfro m(4*1024)

    if not data:
    print "No data."
    break
    else:
    print 'from:', addr, ' data:', data
    UDPSock.close()
  • Fredrik Lundh

    #2
    Re: Simple UDP server

    Tzury Bar Yochay wrote:
    Would the one below will be capable of holding 30 concurrent
    connections?
    UDP is a connectionless datagram protocol, so that question doesn't
    really make much sense.

    </F>

    Comment

    • Tzury Bar Yochay

      #3
      Re: Simple UDP server

      On Sep 10, 9:55 pm, Fredrik Lundh <fred...@python ware.comwrote:
      Tzury Bar Yochay wrote:
      Would the one below will be capable of holding 30 concurrent
      connections?
      >
      UDP is a connectionless datagram protocol, so that question doesn't
      really make much sense.
      >
      So what if it is connectionless.
      It would make sense if you get a load of users who sends large sets of
      binary data to each other.

      Comment

      • Nick Craig-Wood

        #4
        Re: Simple UDP server

        Tzury Bar Yochay <Afro.Systems@g mail.comwrote:
        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
        For UDP I wouldn't thread or, fork, I'd use select and run
        asynchronously.

        This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() av...


        Actually if I really had to do this I'd use twisted. Right tool for
        the job!

        --
        Nick Craig-Wood <nick@craig-wood.com-- http://www.craig-wood.com/nick

        Comment

        • James Mills

          #5
          Re: Simple UDP server

          On Thu, Sep 11, 2008 at 10:36 AM, Nick Craig-Wood <nick@craig-wood.comwrote:
          For UDP I wouldn't thread or, fork, I'd use select and run
          asynchronously.
          >
          This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() av...

          >
          Actually if I really had to do this I'd use twisted. Right tool for
          the job!
          For anyone interested, pymills is an
          event-driven, asynchronous library
          geared towards Component architectures.

          It currently uses select for it's socket
          components, TCPServer, TCPClient,
          and it's UDP counter-parts.

          cheers
          James

          --
          --
          -- "Problems are solved by method"

          Comment

          Working...