A UDP Uppercase Server : UDP : Network PYTHON examples


PYTHON examples » Network » UDP »

 

A UDP Uppercase Server


 

import SocketServer
import netstring
import sys

class MyRequestHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        global Done
        request, socket = self.request
        rq = netstring.decode(request)
        print "From:", self.client_address, ":", rq
        sys.stdout.flush()
        result = netstring.encode(rq.upper())
        if result == "END":
            Done = 1
            return
        socket.sendto(result, self.client_address)

myServer = SocketServer.UDPServer(('', 8081),MyRequestHandler)
Done = None
while not Done:
    myServer.handle_request()

   
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Network
» UDP