0

I have list of socket whic is connected to my 'server program'.if One of clients write something I want to send this message to all clients simutaneously but code below not working simutaneously how can I do this in python

for i in range(len(Connection_list)):
    tempsoc=soc
    if Connection_list[i]==soc:
        reply = "me-->" + message+"\n"
        tempsoc=soc
    else :
        reply = "Message from "+ str(addr[0])+ ":"+ str(addr[1])+"-->" + message +"\n"
        tempsoc=Connection_list[i]
    tempsoc.send(reply.encode('utf-8'))
  • Possible duplicate of [How do multiple clients connect simultaneously to one port, say 80, on a server?](http://stackoverflow.com/questions/3329641/how-do-multiple-clients-connect-simultaneously-to-one-port-say-80-on-a-server) – Aditya May 12 '17 at 20:22
  • This code is not a duplicate of the one labelled (which only tries to explain generic client/server interaction), but it is a bad question that I'm voting to close. @serder, please give a lot more detail: what is `soc`? In what way is it not working? Is it sending any messages? Giving any errors? – Scott Mermelstein May 12 '17 at 21:11
  • @Scott Mermelstein firstly soc is created socket by server when conncetion happen from client , sending message from server to clients whic are in Connection_list not working only current socket working not other connections in list. I am basicaly making simple chat program when one user typing something and hit enter other users must see the message. – serdar özer May 12 '17 at 22:29
  • None of this helps us debug. Please ask a question with a [mcve]. – Scott Mermelstein May 12 '17 at 22:34

0 Answers0