Connect to a host. The optional second argument is the port number, which defaults to the standard telnet port (23). Don't try to reopen an already connected instance.
(self, host, port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT)
| 221 | self.open(host, port, timeout) |
| 222 | |
| 223 | def open(self, host, port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): |
| 224 | """Connect to a host. |
| 225 | |
| 226 | The optional second argument is the port number, which |
| 227 | defaults to the standard telnet port (23). |
| 228 | |
| 229 | Don't try to reopen an already connected instance. |
| 230 | """ |
| 231 | self.eof = 0 |
| 232 | if not port: |
| 233 | port = TELNET_PORT |
| 234 | self.host = host |
| 235 | self.port = port |
| 236 | self.timeout = timeout |
| 237 | sys.audit("telnetlib.Telnet.open", self, host, port) |
| 238 | self.sock = socket.create_connection((host, port), timeout) |
| 239 | |
| 240 | def __del__(self): |
| 241 | """Destructor -- close the connection.""" |
no test coverage detected