Receiving Streaming Data Using the ServerSocket Module : ServerSocket : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » ServerSocket »

 

Receiving Streaming Data Using the ServerSocket Module


import SocketServer
import socket
import string

class myTCPServer(SocketServer.StreamRequestHandler):
    def handle (self):
        while 1:
            peer = self.connection.getpeername()[0]
            line = self.rfile.readline()
            print "%s wrote: %s" (peer, line)
            sck = self.connection.getsockname()[0]
            self.wfile.write("%s: %d bytes 
                successfuly received." 
                (sck, len(line)))

serv = SocketServer.TCPServer(("",50008),myTCPServer)

serv.serve_forever()



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Network
» ServerSocket