title: multiple client server with python
body: <p>I wrote a client and server program through the multi-threaded module, but I have a problem with the code</p>
  
  <p>Consider the following output: (Clients are more than 2 (this is an example))</p>
  
  <pre><code>+---------+--------------+--------+
  | [Index] | [IP-Address] | [Port] |
  +---------+--------------+--------+
  |    0    | 192.168.1.12 | 34224  |
  |    1    | 192.168.1.10 | 39870  |
  +---------+--------------+--------+
  </code></pre>
  
  <p>I want the server to send the corresponding command to the clients when the user enters the "chose [number]" command (like chose 0 1)</p>
  
  <p>If user sending wrong number, like:</p>
  
  <pre><code>chose 2 3
  chose 0 2
  chose 2 0
  chose
  chose 0 (just one number)
  </code></pre>
  
  <p>Server show invalid selection</p>
  
  <p>My output:</p>
  
  <pre><code>+---------+--------------+--------+
  | [Index] | [IP-Address] | [Port] |
  +---------+--------------+--------+
  |    0    | 192.168.1.12 | 34232  |
  |    1    | 192.168.1.10 | 40032  |
  +---------+--------------+--------+
  [BAT]&gt; chose    
  [ERROR] Chose more than one!
  [BAT]&gt; chose 2 3
  [WARNING] Not valid selection
  [WARNING] Not valid selection
  [BAT]&gt; chose 
  [ERROR] Chose more than one!
  [BAT]&gt; chose 0  
  [ERROR] Chose more than one!
  [BAT]&gt; chose 0 1
  [Multicasting-CMD]&gt; mkdir test2
  [STATUS] Success
  [Multicasting-CMD]&gt; 
  [WARNING] Command is empty!
  [BAT]&gt; 
  [WARNING] Command is empty!
  </code></pre>
  
  <p>And my code:</p>
  
  <pre><code>if "chose" in COMMAND:
      Multicasting_check()
  
  
  def Multicasting_check(COMMAND):
      Target_list = COMMAND.replace("chose ", "")
      Target_list = Target_list.split()
  
      checking_list = []
  
      if len(Target_list) &gt; 1:
  
          for conn_item in ALL_CONNECTIONS:
              checking_list.append(ALL_CONNECTIONS.index(conn_item))
  
          for Items in Target_list:
              Int_items = int(Items)
  
              if Int_items in checking_list:
                  Multicasting(Int_items)
              else:
                  print "[WARNING] Not valid selection"
                  continue
      else:
          print "[ERROR] Chose more than one!"
  
  
  
  
  def Multicasting(Conn_number):
      Message = raw_input("[Multicasting-CMD]&gt; ")
  
      if len(Message) &gt; 0:
          if Message == "quit":
              BAT()
  
          try:
              ALL_CONNECTIONS[Conn_number].send(str.encode(Message))
              print colored("[STATUS]", "blue"), colored("Success", "green")
          except socket.error:
              print "[ERROR] Connection was lost with", ALL_HOST_ADDRESSES[Conn_number][0]
      else:
          print "[WARNING] Command is empty!"
  </code></pre>
  
  <p>All clients can't execute the commands
  How can i fix it?</p>
  
  <p>Thanks guys</p>