annotate Doc/lib/libtelnetlib.tex @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 36de5a731257
children 89e35cdbeccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{telnetlib} ---
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 Telnet client}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{telnetlib}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 \modulesynopsis{Telnet client class.}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
6 \sectionauthor{Skip Montanaro}{skip@mojam.com}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7
18413
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
8 \index{protocol!Telnet}
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
9
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 The \module{telnetlib} module provides a \class{Telnet} class that
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11 implements the Telnet protocol. See \rfc{854} for details about the
19760
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
12 protocol. In addition, it provides symbolic constants for the protocol
26017
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
13 characters (see below), and for the telnet options. The
19760
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
14 symbolic names of the telnet options follow the definitions in
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
15 \code{arpa/telnet.h}, with the leading \code{TELOPT_} removed. For
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
16 symbolic names of options which are traditionally not included in
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
17 \code{arpa/telnet.h}, see the module source itself.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18
26017
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
19 The symbolic constants for the telnet commands are: IAC, DONT, DO,
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
20 WONT, WILL, SE (Subnegotiation End), NOP (No Operation), DM (Data
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
21 Mark), BRK (Break), IP (Interrupt process), AO (Abort output), AYT
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
22 (Are You There), EC (Erase Character), EL (Erase Line), GA (Go Ahead),
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
23 SB (Subnegotiation Begin).
36de5a731257 Document symbolic constants for commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 26010
diff changeset
24
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
26 \begin{classdesc}{Telnet}{\optional{host\optional{, port}}}
18413
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
27 \class{Telnet} represents a connection to a Telnet server. The
12569
9a97a714a1be Clarify status of connection of a new instance; it *is* connected if
Fred Drake <fdrake@acm.org>
parents: 12501
diff changeset
28 instance is initially not connected by default; the \method{open()}
9a97a714a1be Clarify status of connection of a new instance; it *is* connected if
Fred Drake <fdrake@acm.org>
parents: 12501
diff changeset
29 method must be used to establish a connection. Alternatively, the
9a97a714a1be Clarify status of connection of a new instance; it *is* connected if
Fred Drake <fdrake@acm.org>
parents: 12501
diff changeset
30 host name and optional port number can be passed to the constructor,
9a97a714a1be Clarify status of connection of a new instance; it *is* connected if
Fred Drake <fdrake@acm.org>
parents: 12501
diff changeset
31 to, in which case the connection to the server will be established
9a97a714a1be Clarify status of connection of a new instance; it *is* connected if
Fred Drake <fdrake@acm.org>
parents: 12501
diff changeset
32 before the constructor returns.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 Do not reopen an already connected instance.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 This class has many \method{read_*()} methods. Note that some of them
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 raise \exception{EOFError} when the end of the connection is read,
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 because they can return an empty string for other reasons. See the
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
39 individual descriptions below.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 \end{classdesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42
12501
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
43 \begin{seealso}
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
44 \seerfc{854}{Telnet Protocol Specification}{
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
45 Definition of the Telnet protocol.}
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
46 \end{seealso}
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
47
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
48
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
49
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 \subsection{Telnet Objects \label{telnet-objects}}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 \class{Telnet} instances have the following methods:
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
54
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
55 \begin{methoddesc}{read_until}{expected\optional{, timeout}}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
56 Read until a given string is encountered or until timeout.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
57
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
58 When no match is found, return whatever is available instead,
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
59 possibly the empty string. Raise \exception{EOFError} if the connection
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
60 is closed and no cooked data is available.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
61 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
62
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
63 \begin{methoddesc}{read_all}{}
21062
bc02c3b09626 Clean up some markup cruft. A number of the macros that take no
Fred Drake <fdrake@acm.org>
parents: 19760
diff changeset
64 Read all data until \EOF; block until connection closed.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
65 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
66
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
67 \begin{methoddesc}{read_some}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
68 Read at least one byte of cooked data unless \EOF{} is hit.
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
69 Return \code{''} if \EOF{} is hit. Block if no data is immediately
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
70 available.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
71 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
72
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
73 \begin{methoddesc}{read_very_eager}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
74 Read everything that can be without blocking in I/O (eager).
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
75
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
76 Raise \exception{EOFError} if connection closed and no cooked data
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
77 available. Return \code{''} if no cooked data available otherwise.
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
78 Do not block unless in the midst of an IAC sequence.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
79 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
80
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
81 \begin{methoddesc}{read_eager}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
82 Read readily available data.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
83
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
84 Raise \exception{EOFError} if connection closed and no cooked data
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
85 available. Return \code{''} if no cooked data available otherwise.
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
86 Do not block unless in the midst of an IAC sequence.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
87 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
88
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
89 \begin{methoddesc}{read_lazy}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
90 Process and return data already in the queues (lazy).
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
91
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
92 Raise \exception{EOFError} if connection closed and no data available.
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
93 Return \code{''} if no cooked data available otherwise. Do not block
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
94 unless in the midst of an IAC sequence.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
95 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
96
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
97 \begin{methoddesc}{read_very_lazy}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
98 Return any data available in the cooked queue (very lazy).
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
99
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
100 Raise \exception{EOFError} if connection closed and no data available.
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
101 Return \code{''} if no cooked data available otherwise. This method
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
102 never blocks.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
103 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
104
26010
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
105 \begin{methoddesc}{read_sb_data}{}
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
106 Return the data collected between a SB/SE pair (suboption begin/end).
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
107 The callback should access these data when it was invoked with a
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
108 \code{SE} command. This method never blocks.
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
109
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
110 \versionadded{2.3}
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
111 \end{methoddesc}
36ea31bc9076 Patch #630829: Don't block on IAC, process suboptions.
Martin v. Löwis <martin@v.loewis.de>
parents: 21062
diff changeset
112
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
113 \begin{methoddesc}{open}{host\optional{, port}}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
114 Connect to a host.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
115 The optional second argument is the port number, which
18413
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
116 defaults to the standard Telnet port (23).
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
117
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
118 Do not try to reopen an already connected instance.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
119 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
120
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
121 \begin{methoddesc}{msg}{msg\optional{, *args}}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
122 Print a debug message when the debug level is \code{>} 0.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
123 If extra arguments are present, they are substituted in the
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
124 message using the standard string formatting operator.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
125 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
126
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
127 \begin{methoddesc}{set_debuglevel}{debuglevel}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
128 Set the debug level. The higher the value of \var{debuglevel}, the
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
129 more debug output you get (on \code{sys.stdout}).
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
130 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
131
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
132 \begin{methoddesc}{close}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
133 Close the connection.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
134 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
135
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
136 \begin{methoddesc}{get_socket}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
137 Return the socket object used internally.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
138 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
139
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
140 \begin{methoddesc}{fileno}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
141 Return the file descriptor of the socket object used internally.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
142 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
143
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
144 \begin{methoddesc}{write}{buffer}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 Write a string to the socket, doubling any IAC characters.
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
146 This can block if the connection is blocked. May raise
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
147 \exception{socket.error} if the connection is closed.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
148 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
149
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
150 \begin{methoddesc}{interact}{}
18413
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
151 Interaction function, emulates a very dumb Telnet client.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
152 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
153
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
154 \begin{methoddesc}{mt_interact}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
155 Multithreaded version of \method{interact()}.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
156 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
157
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
158 \begin{methoddesc}{expect}{list\optional{, timeout}}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
159 Read until one from a list of a regular expressions matches.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
160
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
161 The first argument is a list of regular expressions, either
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
162 compiled (\class{re.RegexObject} instances) or uncompiled (strings).
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
163 The optional second argument is a timeout, in seconds; the default
13625
fdfd1049f36e Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents: 12569
diff changeset
164 is to block indefinitely.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
165
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
166 Return a tuple of three items: the index in the list of the
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
167 first regular expression that matches; the match object
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
168 returned; and the text read up till and including the match.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
169
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
170 If end of file is found and no text was read, raise
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
171 \exception{EOFError}. Otherwise, when nothing matches, return
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
172 \code{(-1, None, \var{text})} where \var{text} is the text received so
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
173 far (may be the empty string if a timeout happened).
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
174
18413
c1e413ef9817 Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
175 If a regular expression ends with a greedy match (such as \regexp{.*})
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
176 or if more than one expression can match the same input, the
13625
fdfd1049f36e Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents: 12569
diff changeset
177 results are indeterministic, and may depend on the I/O timing.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
178 \end{methoddesc}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
179
19760
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
180 \begin{methoddesc}{set_option_negotiation_callback}{callback}
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
181 Each time a telnet option is read on the input flow, this
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
182 \var{callback} (if set) is called with the following parameters :
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
183 callback(telnet socket, command (DO/DONT/WILL/WONT), option). No other
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
184 action is done afterwards by telnetlib.
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
185 \end{methoddesc}
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
186
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
187
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
188 \subsection{Telnet Example \label{telnet-example}}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
189 \sectionauthor{Peter Funk}{pf@artcom-gmbh.de}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
190
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
191 A simple example illustrating typical use:
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
192
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
193 \begin{verbatim}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
194 import getpass
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
195 import sys
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
196 import telnetlib
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
197
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
198 HOST = "localhost"
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
199 user = raw_input("Enter your remote account: ")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
200 password = getpass.getpass()
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
201
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
202 tn = telnetlib.Telnet(HOST)
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
203
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
204 tn.read_until("login: ")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
205 tn.write(user + "\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
206 if password:
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
207 tn.read_until("Password: ")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
208 tn.write(password + "\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
209
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
210 tn.write("ls\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
211 tn.write("exit\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
212
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
213 print tn.read_all()
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
214 \end{verbatim}