myserver changed so its running
This commit is contained in:
parent
4fbe570e1d
commit
90b51fea44
16
myserver.py
16
myserver.py
@ -9,22 +9,24 @@ class ClientThread(threading.Thread):
|
|||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.port = port
|
self.port = port
|
||||||
self.csocket = clientsocket
|
self.csocket = clientsocket
|
||||||
print "[+] New thread started for "+ip+":"+str(port)
|
print("[+] New thread started for ",ip,":",str(port))
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
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"
|
data = "dummydata"
|
||||||
|
|
||||||
while len(data):
|
while len(data):
|
||||||
data = self.csocket.recv(2048)
|
data = self.csocket.recv(2048)
|
||||||
print "Client(%s:%s) sent : %s"%(self.ip, str(self.port), data)
|
print("Client(%s:%s) sent : %s"%(self.ip, str(self.port), data))
|
||||||
self.csocket.send("You sent me : "+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"
|
host = "0.0.0.0"
|
||||||
port = 9999
|
port = 9999
|
||||||
@ -38,7 +40,7 @@ tcpsock.bind((host,port))
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
tcpsock.listen(4)
|
tcpsock.listen(4)
|
||||||
print "\nListening for incoming connections..."
|
print("\nListening for incoming connections...")
|
||||||
(clientsock, (ip, port)) = tcpsock.accept()
|
(clientsock, (ip, port)) = tcpsock.accept()
|
||||||
newthread = ClientThread(ip, port, clientsock)
|
newthread = ClientThread(ip, port, clientsock)
|
||||||
newthread.start()
|
newthread.start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user