original_docstring: __negotiatesocks4(self,destaddr,destport)
  		Negotiates a connection through a SOCKS4 server.
  		
docstring: negotiatesocks4(self,destaddr,destport)
  Negotiates a connection through a SOCKS4 server.
docstring_tokens: negotiatesocks4 ( self destaddr destport ) Negotiates a connection through a SOCKS4 server .
code: def __negotiatesocks4(self,destaddr,destport):
  		"""__negotiatesocks4(self,destaddr,destport)
  		Negotiates a connection through a SOCKS4 server.
  		"""
  		# Check if the destination address provided is an IP address
  		rmtrslv = False
  		try:
  			ipaddr = socket.inet_aton(destaddr)
  		except socket.error:
  			# It's a DNS name. Check where it should be resolved.
  			if self.__proxy[3]==True:
  				ipaddr = "\x00\x00\x00\x01"
  				rmtrslv = True
  			else:
  				ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
  		# Construct the request packet
  		req = "\x04\x01" + struct.pack(">H",destport) + ipaddr
  		# The username parameter is considered userid for SOCKS4
  		if self.__proxy[4] != None:
  			req = req + self.__proxy[4]
  		req = req + "\x00"
  		# DNS name if remote resolving is required
  		# NOTE: This is actually an extension to the SOCKS4 protocol
  		# called SOCKS4A and may not be supported in all cases.
  		if rmtrslv==True:
  			req = req + destaddr + "\x00"
  		self.sendall(req)
  		# Get the response from the server
  		resp = self.__recvall(8)
  		if resp[0] != "\x00":
  			# Bad data
  			self.close()
  			raise GeneralProxyError((1,_generalerrors[1]))
  		if resp[1] != "\x5A":
  			# Server returned an error
  			self.close()
  			if ord(resp[1]) in (91,92,93):
  				self.close()
  				raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90]))
  			else:
  				raise Socks4Error((94,_socks4errors[4]))
  		# Get the bound address/port
  		self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",resp[2:4])[0])
  		if rmtrslv != None:
  			self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)
  		else:
  			self.__proxypeername = (destaddr,destport)
code_tokens: def __negotiatesocks4 ( self , destaddr , destport ) : rmtrslv = False try : ipaddr = socket . inet_aton ( destaddr ) except socket . error : if self . __proxy [ 3 ] == True : ipaddr = "\x00\x00\x00\x01" rmtrslv = True else : ipaddr = socket . inet_aton ( socket . gethostbyname ( destaddr ) ) req = "\x04\x01" + struct . pack ( ">H" , destport ) + ipaddr if self . __proxy [ 4 ] != None : req = req + self . __proxy [ 4 ] req = req + "\x00" if rmtrslv == True : req = req + destaddr + "\x00" self . sendall ( req ) resp = self . __recvall ( 8 ) if resp [ 0 ] != "\x00" : self . close ( ) raise GeneralProxyError ( ( 1 , _generalerrors [ 1 ] ) ) if resp [ 1 ] != "\x5A" : self . close ( ) if ord ( resp [ 1 ] ) in ( 91 , 92 , 93 ) : self . close ( ) raise Socks4Error ( ( ord ( resp [ 1 ] ) , _socks4errors [ ord ( resp [ 1 ] ) - 90 ] ) ) else : raise Socks4Error ( ( 94 , _socks4errors [ 4 ] ) ) self . __proxysockname = ( socket . inet_ntoa ( resp [ 4 : ] ) , struct . unpack ( ">H" , resp [ 2 : 4 ] ) [ 0 ] ) if rmtrslv != None : self . __proxypeername = ( socket . inet_ntoa ( ipaddr ) , destport ) else : self . __proxypeername = ( destaddr , destport )
short_docstring: __negotiatesocks4(self,destaddr,destport)
  Negotiates a connection through a SOCKS4 server.
short_docstring_tokens: __negotiatesocks4 ( self destaddr destport ) Negotiates a connection through a SOCKS4 server .
comment: """__negotiatesocks4(self,destaddr,destport)
  		Negotiates a connection through a SOCKS4 server.
  		"""$SEP$# Check if the destination address provided is an IP address
  $SEP$# It's a DNS name. Check where it should be resolved.
  $SEP$# Construct the request packet
  $SEP$# The username parameter is considered userid for SOCKS4
  $SEP$# DNS name if remote resolving is required
  $SEP$# NOTE: This is actually an extension to the SOCKS4 protocol
  $SEP$# called SOCKS4A and may not be supported in all cases.
  $SEP$# Get the response from the server
  $SEP$# Bad data
  $SEP$# Server returned an error
  $SEP$# Get the bound address/port
  