Connecting to socket with authentication in python
问题 I'm trying to connect to a mongodb instance through a python socket. The url looks like this username:password@host.com:port how can I connect to this with a python socket? The following code gives me this error: [Errno -5] No address associated with hostname import socket import tornado full_url = '%s:%s@%s' % (username, password, host) s = socket.socket() s.connect((full_url, port)) stream = iostream.IOStream(s) EDIT - the reason I ask is because asyncmongo doesn't support this type of url