Python Chat Server – 3 – New server code and allowing multiple users via Threading



todd.martin@solidshellsecurity.com

Remember this needs to be formatted properly when copy and pasting!
Source Code:
from socket import *
from threading import Thread

def clientHandler():
conn, addr = s.accept()
print addr, “is Connected”
while 1:
data = conn.recv(1024)
if not data:
break
print “Received Message”, repr(data)

HOST = ” #localhost
PORT = 8000

s = socket(AF_INET, SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(5)

print “Server is running……”

#Thread(target=clientHandler).start()
#Thread(target=clientHandler).start()
#Thread(target=clientHandler).start()

for i in range(5):
Thread(target=clientHandler).start()

s.close()

To comment on this video please visit the following:

http://community.solidshellsecurity.com/topic/


- Post Time: 01-04-18 - By: http://www.phoenixchem.net