annotate Doc/lib/libtelnetlib.tex @ 21467:4e35fa5d5708 legacy-trunk

Add documentation for the help() built-in; contributed by Ka-Ping Yee. This is part of SF patch #494622.
author Fred Drake <fdrake@acm.org>
date Tue, 18 Dec 2001 16:31:08 +0000
parents bc02c3b09626
children b18d2f2db18d 36ea31bc9076
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
96da985cde98 Patch #416079: fix the debug string output when receiving telnet commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 18413
diff changeset
13 characters (IAC/DONT/DO/WONT/WILL), and for the telnet options. The
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
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
20 \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
21 \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
22 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
23 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
24 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
25 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
26 before the constructor returns.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 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
29
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 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
31 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
32 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
33 individual descriptions below.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 \end{classdesc}
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
12501
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
37 \begin{seealso}
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
38 \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
39 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
40 \end{seealso}
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
41
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
42
bd92c53b1669 Added a "See also:" section that exhibits the \seerfc markup.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
43
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
44 \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
45
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
46 \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
47
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
49 \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
50 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
51
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 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
53 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
54 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
55 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
56
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
57 \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
58 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
59 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
60
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
61 \begin{methoddesc}{read_some}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
62 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
63 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
64 available.
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_very_eager}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
68 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
69
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
70 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
71 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
72 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
73 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
74
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
75 \begin{methoddesc}{read_eager}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
76 Read readily available data.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
77
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
78 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
79 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
80 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
81 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
82
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
83 \begin{methoddesc}{read_lazy}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
84 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
85
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
86 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
87 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
88 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
89 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
90
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
91 \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
92 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
93
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
94 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
95 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
96 never blocks.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
97 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
98
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
99 \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
100 Connect to a host.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
101 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
102 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
103
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
104 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
105 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
106
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
107 \begin{methoddesc}{msg}{msg\optional{, *args}}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
108 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
109 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
110 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
111 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
112
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
113 \begin{methoddesc}{set_debuglevel}{debuglevel}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
114 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
115 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
116 \end{methoddesc}
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 \begin{methoddesc}{close}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
119 Close the connection.
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
120 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
121
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
122 \begin{methoddesc}{get_socket}{}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
123 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
124 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
125
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
126 \begin{methoddesc}{fileno}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
127 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
128 \end{methoddesc}
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
129
10692
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
130 \begin{methoddesc}{write}{buffer}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
131 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
132 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
133 \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
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}{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
137 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
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}{mt_interact}{}
d30ccb00bd7b Clean up lots of mark up.
Fred Drake <fdrake@acm.org>
parents: 10396
diff changeset
141 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
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}{expect}{list\optional{, timeout}}
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 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
146
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
147 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
148 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
149 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
150 is to block indefinitely.
10396
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
151
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
152 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
153 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
154 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
155
c066fd8433ba Preliminary mhlib and telnetlib documents from Skip Montanaro -- thanks, Skip!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
156 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
157 \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
158 \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
159 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
160
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
161 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
162 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
163 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
164 \end{methoddesc}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
165
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
166 \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
167 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
168 \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
169 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
170 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
171 \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
172
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
173
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
174 \subsection{Telnet Example \label{telnet-example}}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
175 \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
176
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
177 A simple example illustrating typical use:
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
178
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
179 \begin{verbatim}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
180 import getpass
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
181 import sys
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
182 import telnetlib
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
183
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
184 HOST = "localhost"
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
185 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
186 password = getpass.getpass()
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 tn = telnetlib.Telnet(HOST)
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
189
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
190 tn.read_until("login: ")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
191 tn.write(user + "\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
192 if password:
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
193 tn.read_until("Password: ")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
194 tn.write(password + "\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
195
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
196 tn.write("ls\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
197 tn.write("exit\n")
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
198
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
199 print tn.read_all()
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10692
diff changeset
200 \end{verbatim}