MCPcopy Index your code
hub / github.com/python/cpython / connect

Method connect

Lib/ftplib.py:139–163  ·  view source on GitHub ↗

Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port) - timeout: the timeout to set against the ftp socket(s) - source_address: a 2-tuple (host, port) for the soc

(self, host='', port=0, timeout=-999, source_address=None)

Source from the content-addressed store, hash-verified

137 self.close()
138
139 def connect(self, host='', port=0, timeout=-999, source_address=None):
140 '''Connect to host. Arguments are:
141 - host: hostname to connect to (string, default previous host)
142 - port: port to connect to (integer, default previous port)
143 - timeout: the timeout to set against the ftp socket(s)
144 - source_address: a 2-tuple (host, port) for the socket to bind
145 to as its source address before connecting.
146 '''
147 if host != '':
148 self.host = host
149 if port > 0:
150 self.port = port
151 if timeout != -999:
152 self.timeout = timeout
153 if self.timeout is not None and not self.timeout:
154 raise ValueError('Non-blocking socket (timeout=0) is not supported')
155 if source_address is not None:
156 self.source_address = source_address
157 sys.audit("ftplib.connect", self, self.host, self.port)
158 self.sock = socket.create_connection((self.host, self.port), self.timeout,
159 source_address=self.source_address)
160 self.af = self.sock.family
161 self.file = self.sock.makefile('r', encoding=self.encoding)
162 self.welcome = self.getresp()
163 return self.welcome
164
165 def getwelcome(self):
166 '''Get the welcome message from the server.

Callers 12

__init__Method · 0.95
testTimeoutConnectMethod · 0.95
mainFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
_fallback_socketpairFunction · 0.45
create_connectionFunction · 0.45

Calls 3

getrespMethod · 0.95
create_connectionMethod · 0.45
makefileMethod · 0.45

Tested by 3

testTimeoutConnectMethod · 0.76