title: Socket an invalid argument was supplied in python
body: <pre><code>import socket
  from _thread import *
  import pickle
  
  server = &quot;192.168.0.171&quot;
  port = 5555
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  try:
      s.bind((server, port))
  except socket.error as e:
      str(e)
  
  s.listen(2)
  print(&quot;Waiting for connection, Server Started&quot;)
  
  
  def read_pos(str):  # Get position
      str = str.split(&quot;,&quot;)
      return int(str[0]), int(str[1]), int(str[2]), int(str[3]), int(str[4]), int(str[5])
  
  
  def make_pos(tup, n1, n2, n3):  # Make a position
      return str(tup[0]) + &quot;,&quot; + str(tup[1]) + &quot;,&quot; + str(n1) + &quot;,&quot; + str(n2) + &quot;,&quot; + str(n3)
  
  
  pos = [(200, 225, 0, 0, 0), (750, 225, 0, 0, 0)]
  
  
  def threaded_client(conn, player):
      # Make sure it indeed connect
      conn.send(str.encode(make_pos(pos[player])))
      reply = &quot;&quot;
      while True:
          try:
              # Amount of info receive = 2048
              data = read_pos(conn.recv(2048).decode())
              pos[player] = data
              if player == 1:
                  reply = pos[0]
              else:
                  reply = pos[1]
  
  
              if not data:
                  print(&quot;Disconnected&quot;)
                  break
              else:
                  print(&quot;Received: &quot;, data)
                  print(&quot;Sending: &quot;, reply)
              conn.sendall(str.encode(make_pos(reply)))
          except:
              break
              # No connection
  
      print(&quot;Lost connection&quot;)
      conn.close()
  
  currentPlayer = 0
  while True:
      conn, addr = s.accept()
      print(&quot;Connected to:&quot;, addr)
  
      start_new_thread(threaded_client, (conn, currentPlayer))
      currentPlayer += 1
  </code></pre>
  <p>Traceback (most recent call last):
  File &quot;C:\Users\HP\PycharmProjects\Online_minigame_01\server.py&quot;, line 15, in 
  s.listen(2)
  OSError: [WinError 10022] An invalid argument was supplied</p>
  <p>So, I tried to make a online 2 player space ship shooting game. But this part(server) could't even run. I had tried many ways and it still won't work. How should I fix it?</p>