errno 107 socket.recv issue

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Feb 9 12:49:51 EST 2010


Jordan Apgar wrote:
>> http://docs.python.org/library/socketserver.html
>>
>> JM
>>     
>
> each time a handler is spawned is it client specific? in other words
> when two clients send something to the server do handlers spawn for
> each of them or does everything just go into a single handler?
>   
docstring of the example:

    """
    The RequestHandler class for our server.

    It is instantiated once per connection to the server, and must
    override the handle() method to implement communication to the
    client.
    """

If you want data persistant over connections, store them in your handler 
class.

class MyTCPHandler(SocketServer.BaseRequestHandler):
    cnxNumber = 0
    def handle(self):
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        # just send back the same data, but upper-cased
        self.request.send(self.data.upper())
        cnxNumber +=1  
	print "handling connection N°%s" % cnxNumber

JM



More information about the Python-list mailing list