python programming hello i m trying to create server client app where multiplesclien 4944822

Python Programming Hello I’m trying to create server-client app where multiplesclients can collaborate painting when they join to a channel oftheir preference and also chat in between when they arecolaborating: I have the code for an app I have created in the passfor booking flights which is a server and a client notice: I erasedall of the methods I had used to create the app however I wouldlike to know how can I structure the code in my server such that ittakes the data from the painting app which I also have the codedone in Tkinter but for a single user. I know I may have to use atimer fuction which would send the data back to the server and theserver to the other clients are collaborating in the painting alsoprobably a channel. Can someone give me a guide to what I need todo?   #Server Code import socket import threading import sys import pickle import json class Server(): locked = False def __init__(self, host=”localhost”, port=10000): self.client = [] self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.sock.bind((str(host), int(port))) self.sock.listen(10) self.sock.setblocking(True) # Should be a blockingconnection self.prompt = ‘Tool options:’ self.acceptCon() # This function runs indefinitely # It keeps on accepting & then initializing server code forconnections def take_input(self, client, prompt): client.send(pickle.dumps(prompt)) client_response = ” # Initialize response variable # Wait indefinitely until a response is seen using blockingconnection while client_response is None or len(client_response) == 0: client_response = client.recv(1024) # Parse the response client_response = pickle.loads(client_response) return client_response def msg_to_all(self, msg, cliente): for c in self.client: try: if c != cliente: c.send(msg) except: self.client.remove(c) def processCon(self, connection): c = connection response = self.take_input( client=c, prompt=self.prompt ) print(“Received “, response) if response == ‘draw’: self.sock.close() sys.exit() else: pass def acceptCon(self): print(“Connection has been established”) while True: try: conn, saddr = self.sock.accept() conn.setblocking(True) self.client.append(conn) handler = threading.Thread( target=self.processCon, kwargs={“connection”: conn} ) handler.daemon = True handler.start() except: pass s = Server() Client Code# import socket import threading import sys import pickle class Client(): “””docstring for Cliente””” def __init__(self, host=”localhost”, port=10000): self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.sock.connect((str(host), int(port))) msg_recv = threading.Thread(target=self.msg_recv) msg_recv.daemon = True msg_recv.start() while True: msg = input(‘->n’) if msg != ‘exit’: self.send_msg(msg) else: self.sock.close() sys.exit() def msg_recv(self): while True: try: data = self.sock.recv(1024) if data: print(pickle.loads(data)) except: pass def send_msg(self, msg): self.sock.send(pickle.dumps(msg)) c = Client() . . .

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now