Client/Server based on SocketServer and Windows

Kiki julien.chevalier at gmail.com
Sun Aug 9 12:22:40 EDT 2009


Hello list,

I've written a small Client/server system.
Basically, i'm expecting something like : The client sends every once
and a while a small data chunk (not more than 50 bytes) the server
receive it and print it.

Here is the server request handler :

class ThreadedTCPRequestHandlerFoo(SocketServer.BaseRequestHandler):

    def handle(self):
	    data = self.request.recv(1024)
	    cur_thread = threading.currentThread()
            response = "%s: %s from Foo" % (cur_thread.getName(),
data)
            print response

and this is the client :

def clientPrompt(ip, port, message):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((ip, port))
	while(1):
		k=raw_input('#>')
		sock.send(k)
		print "%s\n" % k
		if k == 'quit': break
        sock.close()

My problem comes from that I can't send data from client more than
once without having the following Winsock error : 10053 Software
caused connection abort.
I have to restart the client each time I want to send a new message.

Could anyboy explain me why ?

Regards



More information about the Python-list mailing list