python - Handling client threads -


i have learned in client server network there multiple client processes running in different systems , there 1 server process running in server machine. when server receives connection client creates new thread , handles client.

i working on project in client creates multiple threads , server creates multiple threads each client thread.

i cant publish source code project here have written small client server program in python in client creates new thread everytime press key , server should create new thread it.

i getting errors need help.

the code server is

import socket threading import thread  host="10.0.0.5" port=7000 s=socket.socket() s.bind((host, port)) s.listen(10)  def server(c, addr, i):     print("connection successful "+str(addr))     while true:             msg=c.recv(1024)             if not msg:                     break             decoded_msg=msg.decode("utf-8")             print("client "+str(i)+" : "+decoded_msg+"\n")  def main():     i=0     while i<=10:             c, addr=s.accept()             print("triying recieve connection")             t=thread(target=server, args=(c, addr, i))             t.start()             i+=1  main() c.close() 

the code client is

import socket threading import thread import time  host="10.0.0.5" port=7000 s=socket.socket()  def client(i):     s.connect((host, port))     while true:             msg="from client "+str(i)             encoded_msg=bytes(msg, "utf-8")             s.send(encoded_msg)             time.sleep(1)  def main():     i=0     while true:             print("connection request sent")             thread(target=client, args=(i, )).start()             i+=1             if input()=='q':                     break  main() s.close() 


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -