title: socket() function tuple error in python "TypeError: getsockaddrarg: AF_INET address must be tuple, not int"
body: <p>I tried to write a simple python code for send/receive message between server and client sides. When I define my computer as server, I get an error which is written below. Interestingly same code works in another pc. </p>
  
  <p>Code for server:</p>
  
  <pre><code>import socket
  
  s = socket.socket()
  host = '10.1.1.25' # static ip of the server pc
  port = 5001
  s.bind(5)
  c, addr = s.accept()
  print("Got connection from", addr)
  while True:
     c.send("Server please type").encode()
     print("From Server :", c.recv(4096))
  
  c.close()
  </code></pre>
  
  <p>I get this error: </p>
  
  <pre><code>   s.bind(5)
  TypeError: getsockaddrarg: AF_INET address must be tuple, not int
  </code></pre>
  
  <p>I replaced <strong>s.bind(5)</strong> with <strong>s.bind((host,port))</strong> then I get this error:</p>
  
  <pre><code>   fd, addr = self._accept()
  OSError: [WinError 10022] An invalid argument was supplied
  </code></pre>
  
  <p>Code for Client:</p>
  
  <pre><code>import socket
  
  s=socket.socket()
  host="10.1.1.25"
  port=5001
  s.connect((host,port))
  
  while True:
      try:
          print("from server:",s.recv(4096))
          s.send(input("write something").encode())
      except:
          break
  s.close()
  </code></pre>
  
  <p><strong>NOTE:</strong>    <em>I got these errors on windows 8.1,but it works on windows 10<br>
   Client sample code works for each computer which I tried</em></p>
  
  <p>Thanks for your help. According to your recommendations I modified my code like this;</p>
  
  <pre><code>import socket
  
  s = socket.socket()
  host = '10.1.1.25'
  port = 5001
  s.bind((host,port))
  s.listen(5)
  c,addr=s.accept()
  print("Got connection from", addr)
  while True:
      c.send(input("Server please type").encode())
      print("From Server :", c.recv(4096))
  s.close()
  </code></pre>
  
  <p>Now It works on local IP (when I adjusted 127.0.0.1) and I can communicate by myself on one computer.Even though when I try to communicate with second computer, I dont receive any error but I dont get any output</p>