From 90b51fea44e690d71bcba63e117c2e9bb30067d9 Mon Sep 17 00:00:00 2001 From: ademant Date: Fri, 8 Nov 2019 10:56:09 +0100 Subject: [PATCH] myserver changed so its running --- myserver.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/myserver.py b/myserver.py index 27a257a..46c9d98 100644 --- a/myserver.py +++ b/myserver.py @@ -9,22 +9,24 @@ class ClientThread(threading.Thread): self.ip = ip self.port = port self.csocket = clientsocket - print "[+] New thread started for "+ip+":"+str(port) + print("[+] New thread started for ",ip,":",str(port)) def run(self): - print "Connection from : "+ip+":"+str(port) + print("Connection from : ",ip,":",str(port)) - clientsock.send("\nWelcome to the server\n\n") +# clientsock.send("\nWelcome to the server\n\n") + self.csocket.send("\nWelcome to the server\n\n".encode('utf-8')) data = "dummydata" while len(data): data = self.csocket.recv(2048) - print "Client(%s:%s) sent : %s"%(self.ip, str(self.port), data) - self.csocket.send("You sent me : "+data) + print("Client(%s:%s) sent : %s"%(self.ip, str(self.port), data)) + response="You sent me : "+str(data) + self.csocket.send(response.encode('utf-8')) - print "Client at "+self.ip+" disconnected..." + print("Client at ",self.ip," disconnected...") host = "0.0.0.0" port = 9999 @@ -38,8 +40,8 @@ tcpsock.bind((host,port)) while True: tcpsock.listen(4) - print "\nListening for incoming connections..." + print("\nListening for incoming connections...") (clientsock, (ip, port)) = tcpsock.accept() newthread = ClientThread(ip, port, clientsock) newthread.start() - \ No newline at end of file +