parameters: (self)
docstring: Connect to the host and port specified in __init__.
docstring_summary: Connect to the host and port specified in __init__.
docstring_tokens: Connect to the host and port specified in __init__ .
function: def connect(self):
          """Connect to the host and port specified in __init__."""
          # Mostly verbatim from httplib.py.
          if self.proxy_info and socks is None:
              raise ProxiesUnavailableError(
                  'Proxy support missing but proxy use was requested!')
          msg = "getaddrinfo returns an empty list"
          if self.proxy_info and self.proxy_info.isgood():
              use_proxy = True
              proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass = self.proxy_info.astuple()
          else:
              use_proxy = False
          if use_proxy and proxy_rdns:
              host = proxy_host
              port = proxy_port
          else:
              host = self.host
              port = self.port
  
          for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
              af, socktype, proto, canonname, sa = res
              try:
                  if use_proxy:
                      self.sock = socks.socksocket(af, socktype, proto)
                      self.sock.setproxy(proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass)
                  else:
                      self.sock = socket.socket(af, socktype, proto)
                      self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
                  # Different from httplib: support timeouts.
                  if has_timeout(self.timeout):
                      self.sock.settimeout(self.timeout)
                      # End of difference from httplib.
                  if self.debuglevel > 0:
                      print "connect: (%s, %s) ************" % (self.host, self.port)
                      if use_proxy:
                          print "proxy: %s ************" % str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass))
  
                  self.sock.connect((self.host, self.port) + sa[2:])
              except socket.error, msg:
                  if self.debuglevel > 0:
                      print "connect fail: (%s, %s)" % (self.host, self.port)
                      if use_proxy:
                          print "proxy: %s" % str((proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass))
                  if self.sock:
                      self.sock.close()
                  self.sock = None
                  continue
              break
          if not self.sock:
              raise socket.error, msg
function_tokens: def connect ( self ) : # Mostly verbatim from httplib.py. if self . proxy_info and socks is None : raise ProxiesUnavailableError ( 'Proxy support missing but proxy use was requested!' ) msg = "getaddrinfo returns an empty list" if self . proxy_info and self . proxy_info . isgood ( ) : use_proxy = True proxy_type , proxy_host , proxy_port , proxy_rdns , proxy_user , proxy_pass = self . proxy_info . astuple ( ) else : use_proxy = False if use_proxy and proxy_rdns : host = proxy_host port = proxy_port else : host = self . host port = self . port for res in socket . getaddrinfo ( host , port , 0 , socket . SOCK_STREAM ) : af , socktype , proto , canonname , sa = res try : if use_proxy : self . sock = socks . socksocket ( af , socktype , proto ) self . sock . setproxy ( proxy_type , proxy_host , proxy_port , proxy_rdns , proxy_user , proxy_pass ) else : self . sock = socket . socket ( af , socktype , proto ) self . sock . setsockopt ( socket . IPPROTO_TCP , socket . TCP_NODELAY , 1 ) # Different from httplib: support timeouts. if has_timeout ( self . timeout ) : self . sock . settimeout ( self . timeout ) # End of difference from httplib. if self . debuglevel > 0 : print "connect: (%s, %s) ************" % ( self . host , self . port ) if use_proxy : print "proxy: %s ************" % str ( ( proxy_host , proxy_port , proxy_rdns , proxy_user , proxy_pass ) ) self . sock . connect ( ( self . host , self . port ) + sa [ 2 : ] ) except socket . error , msg : if self . debuglevel > 0 : print "connect fail: (%s, %s)" % ( self . host , self . port ) if use_proxy : print "proxy: %s" % str ( ( proxy_host , proxy_port , proxy_rdns , proxy_user , proxy_pass ) ) if self . sock : self . sock . close ( ) self . sock = None continue break if not self . sock : raise socket . error , msg