All this program should do is accept inputs from 2 clients simultaneously and print them out, but instead it accepts 1 input from the first client to connect, then starts accepting inputs infinitely from the second client, but not from the first anymore. Any tips on how to fix this code? (shown below)
import socket
import select
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("127.0.0.1", 4000))
s.listen(5)
sockets = []
sockets.append(s)
while True:
(read, write, err) = select.select(sockets, [], [])
for socket in read:
if (socket == s):
(c, a) = socket.accept()
sockets.append(c)
print ("Received connection from: ", a)
message = c.recv(80).decode()
print (message + " from " + str(a[1]))