I am learning networking and just wrote a primitive client server program.. server: from time import ctimefrom socket import * HOST = ""PORT = 21567BUFSIZ = 1024ADDR = (HOST, PORT) tcpSerSoc = socket(AF_INET, SOCK_STREAM)tcpSerSoc.bind(ADDR)tcpSerSoc.listen(5) while True: print "waiting for connection.." tcpCliSoc, addr = tcpSerSoc.accept() print "# Connected from:", addr while True: data = tcpCliSoc.recv(BUFSIZ) if not data: break tcpCliSoc.send( "[%s] %s" % (ctime(), data )) tcpCliSoc.clock()tcpSerSoc.close() Client: from socket import * HOST = 'localhost'PORT = 21567BUFSIZ = 1024ADDR = (HOST, PORT) tcpCliSoc = socket(AF_INET, SOCK_STREAM)tcpCliSoc.connect(ADDR) while True: data = raw_input(">") if not data: break tcpCliSoc.send(data) data = tcpCliSoc.recv(BUFSIZ) if not data: break print datatcpCliSoc.close() This client sends a string, and receives the same string with current time...
So, I tried to run another client (same code but from different file) but found that its now working. why its happening, should I use multithreading so that I can handle two clients simultaneously??
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor