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

Method connect

Lib/smtplib.py:322–353  ·  view source on GitHub ↗

Connect to a host on a given port. If the hostname ends with a colon (':') followed by a number, and there is no port specified, that suffix will be stripped off and the number interpreted as the port number to use. Note: This method is automatically invoked by __in

(self, host='localhost', port=0, source_address=None)

Source from the content-addressed store, hash-verified

320 self.source_address)
321
322 def connect(self, host='localhost', port=0, source_address=None):
323 """Connect to a host on a given port.
324
325 If the hostname ends with a colon (':') followed by a number, and
326 there is no port specified, that suffix will be stripped off and the
327 number interpreted as the port number to use.
328
329 Note: This method is automatically invoked by __init__, if a host is
330 specified during instantiation.
331
332 """
333
334 if source_address:
335 self.source_address = source_address
336
337 if not port and (host.find(':') == host.rfind(':')):
338 i = host.rfind(':')
339 if i >= 0:
340 host, port = host[:i], host[i + 1:]
341 try:
342 port = int(port)
343 except ValueError:
344 raise OSError("nonnumeric port")
345 if not port:
346 port = self.default_port
347 sys.audit("smtplib.connect", self, host, port)
348 self.sock = self._get_socket(host, port, self.timeout)
349 self.file = None
350 (code, msg) = self.getreply()
351 if self.debuglevel > 0:
352 self._print_debug('connect:', repr(msg))
353 return (code, msg)
354
355 def send(self, s):
356 """Send 's' to the server."""

Callers 4

__init__Method · 0.95
_deliverMethod · 0.95
connectMethod · 0.45

Calls 5

_get_socketMethod · 0.95
getreplyMethod · 0.95
_print_debugMethod · 0.95
findMethod · 0.45
rfindMethod · 0.45

Tested by 1