Receiving Streaming Data Using the ServerSocket Module : ServerSocket « Network « Python Tutorial






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








21.4.ServerSocket
21.4.1.Receiving Streaming Data Using the ServerSocket Module
21.4.2.SocketServer Timestamp TCP Server (tsTservSS.py)
21.4.3.SocketServer Timestamp TCP Client