Im trying to have multiple clients be able to connect to a server however when a second user connects it kicks the other client off the server as you cant have 2 clients connected to a socket and i was wondering if there was anything around this.
server.py
import socket
def Main():
host = '10.41.13.228'
port = 5000
s = socket.socket()
s.bind((host,port))
s.listen(1)
name = input("Please Enter your name - ")
while True:
c, addr = s.accept()
print("Connection from: " + str(addr))
data = c.recv(1024).decode('utf-8')
print(data)
c.close()
if __name__ == '__main__':
Main()
Client.py
import socket
def Main():
host = '10.41.13.228'
port = 5000
s = socket.socket()
s.connect((host, port))
name = input("Please enter your name - ")
message = input("-> ")
while True:
while message != 'q':
ToSend = (str(name) + " - " + str(message))
s.sendall(ToSend.encode('utf-8'))
message = input("-> ")
s.close()
if __name__ == '__main__':
Main()