From: r. clayton on

> 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?
From: Jordan Apgar on

> 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?
From: Jean-Michel Pichavant on
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
From: Jordan Apgar on
thanks JM,

at this point i switched over to this scheme and now I'm getting an
error durring instantiation of the server:
Server.py:
from Crypto.PublicKey import RSA
from ServerNegotiator import ServerNegotiator
from sharedComs import *

f = open("hostid")
tup = stringToTuple(f.readline()[0:-1])
HostID = f.readline()[0:-1]
f.close()

key = RSA.construct((long(tup[0]),long(tup[1]), long(tup[2]),
long(tup[3]),
long(tup[4]),long(tup[5])))
host = "localhost"
port = 8005

servernegotiator = ServerNegotiator(host,HostID, port, key)
servernegotiator.start()


ServerNegotiatior.py lines 185 - end
class ServerNegotiator:
def __init__(self, host, port, hostid, rsa_key, buf = 512):
negotiator = Negotiator(host, hostid, rsa_key,buf)
self.server = SocketServer.TCPServer((host, port), negotiator)

def start(self):
self.server.serve_forever()





Traceback (most recent call last):
File "Server.py", line 16, in <module>
servernegotiator = ServerNegotiator(host,HostID, port, key)
File "/home/twistedphrame/Desktop/communication/
ServerNegotiator.py", line 188, in __init__
self.server = SocketServer.TCPServer((host, port), negotiator)
File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
self.server_bind()
File "/usr/lib/python2.6/SocketServer.py", line 411, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
TypeError: an integer is required

From: George Trojan on
Argument mismatch?

Jordan Apgar wrote:
>
> servernegotiator = ServerNegotiator(host,HostID, port, key)
>
> class ServerNegotiator:
> def __init__(self, host, port, hostid, rsa_key, buf = 512):
>