title: How to connect python socket client side to server socket with url?
body: <p>I am trying to create a client to connect to a server with given url address.</p>
  
  <p>I used this way</p>
  
  <pre><code>host_ip = socket.gethostbyname('HOST_NAME')
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.bind(('127.0.0.1', 0))
  sock.connect((host_ip, 8080))
  </code></pre>
  
  <p>but it printed the following error</p>
  
  <pre><code>OSError: [Errno 22] Invalid argument
  </code></pre>
  
  <p>Can someone explain me why is wrong and give me a solution?</p>