Telnet interface class. An instance of this class represents a connection to a telnet server. The instance is initially not connected; the open() method must be used to establish a connection. Alternatively, the host name and optional port number can be passed to the con
| 142 | |
| 143 | |
| 144 | class Telnet: |
| 145 | |
| 146 | """Telnet interface class. |
| 147 | |
| 148 | An instance of this class represents a connection to a telnet |
| 149 | server. The instance is initially not connected; the open() |
| 150 | method must be used to establish a connection. Alternatively, the |
| 151 | host name and optional port number can be passed to the |
| 152 | constructor, too. |
| 153 | |
| 154 | Don't try to reopen an already connected instance. |
| 155 | |
| 156 | This class has many read_*() methods. Note that some of them |
| 157 | raise EOFError when the end of the connection is read, because |
| 158 | they can return an empty string for other reasons. See the |
| 159 | individual doc strings. |
| 160 | |
| 161 | read_until(expected, [timeout]) |
| 162 | Read until the expected string has been seen, or a timeout is |
| 163 | hit (default is no timeout); may block. |
| 164 | |
| 165 | read_all() |
| 166 | Read all data until EOF; may block. |
| 167 | |
| 168 | read_some() |
| 169 | Read at least one byte or EOF; may block. |
| 170 | |
| 171 | read_very_eager() |
| 172 | Read all data available already queued or on the socket, |
| 173 | without blocking. |
| 174 | |
| 175 | read_eager() |
| 176 | Read either data already queued or some data available on the |
| 177 | socket, without blocking. |
| 178 | |
| 179 | read_lazy() |
| 180 | Read all data in the raw queue (processing it first), without |
| 181 | doing any socket I/O. |
| 182 | |
| 183 | read_very_lazy() |
| 184 | Reads all data in the cooked queue, without doing any socket |
| 185 | I/O. |
| 186 | |
| 187 | read_sb_data() |
| 188 | Reads available data between SB ... SE sequence. Don't block. |
| 189 | |
| 190 | set_option_negotiation_callback(callback) |
| 191 | Each time a telnet option is read on the input flow, this callback |
| 192 | (if set) is called with the following parameters : |
| 193 | callback(telnet socket, command, option) |
| 194 | option will be chr(0) when there is no option. |
| 195 | No other action is done afterwards by telnetlib. |
| 196 | |
| 197 | """ |
| 198 | |
| 199 | def __init__(self, host=None, port=0, |
| 200 | timeout=socket._GLOBAL_DEFAULT_TIMEOUT): |
| 201 | """Constructor. |