s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
"""
    ***********************************************************************************
    * Note that the connect() operation is subject to the timeout setting,
    * and in general it is recommended to call settimeout() before calling connect()
    * or pass a timeout parameter to create_connection().
    * The system network stack may return a connection timeout error of its own
    * regardless of any Python socket timeout setting.
    ***********************************************************************************
    """
s.settimeout(0.3)
"""
    **************************************************************************************
    * Avoid socket.error: [Errno 98] Address already in use exception
    * The SO_REUSEADDR flag tells the kernel to reuse a local socket in TIME_WAIT state,
    * without waiting for its natural timeout to expire.
    **************************************************************************************
    """
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.connect((HOST, PORT))
s.send('GET / HTTP/1.0%s' % CRLF)
data = s.recv(1000000)
print(data)
s.shutdown(1)
s.close()
print('Received', repr(data))
GET('http://www.google.com')
Creating a raw HTTP request with sockets