parameters: (self)
return_statement: return sock
docstring: Create a new socket and send a PORT command for it.
docstring_summary: Create a new socket and send a PORT command for it.
docstring_tokens: Create a new socket and send a PORT command for it .
function: def makeport(self):
          '''Create a new socket and send a PORT command for it.'''
          msg = "getaddrinfo returns an empty list"
          sock = None
          for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
              af, socktype, proto, canonname, sa = res
              try:
                  sock = socket.socket(af, socktype, proto)
                  sock.bind(sa)
              except socket.error, msg:
                  if sock:
                      sock.close()
                  sock = None
                  continue
              break
          if not sock:
              raise socket.error, msg
          sock.listen(1)
          port = sock.getsockname()[1] # Get proper port
          host = self.sock.getsockname()[0] # Get proper host
          if self.af == socket.AF_INET:
              resp = self.sendport(host, port)
          else:
              resp = self.sendeprt(host, port)
          if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
              sock.settimeout(self.timeout)
          return sock
function_tokens: def makeport ( self ) : msg = "getaddrinfo returns an empty list" sock = None for res in socket . getaddrinfo ( None , 0 , self . af , socket . SOCK_STREAM , 0 , socket . AI_PASSIVE ) : af , socktype , proto , canonname , sa = res try : sock = socket . socket ( af , socktype , proto ) sock . bind ( sa ) except socket . error , msg : if sock : sock . close ( ) sock = None continue break if not sock : raise socket . error , msg sock . listen ( 1 ) port = sock . getsockname ( ) [ 1 ] # Get proper port host = self . sock . getsockname ( ) [ 0 ] # Get proper host if self . af == socket . AF_INET : resp = self . sendport ( host , port ) else : resp = self . sendeprt ( host , port ) if self . timeout is not _GLOBAL_DEFAULT_TIMEOUT : sock . settimeout ( self . timeout ) return sock