1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
"DTD/xhtml1-transitional.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>twisted.protocols.policies.TimeoutProtocol</title>
7
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
9
<body bgcolor="white" text="black" link="blue" vlink="#204080"
12
<!-- =========== START OF NAVBAR =========== -->
13
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
15
<th class="navbar"> <a class="navbar" href="twisted.html">Home</a> </th>
16
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
17
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
18
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
19
<th class="navbar" align="right" width="100%">
20
<table border="0" cellpadding="0" cellspacing="0">
21
<tr><th class="navbar" align="center">
23
<a class="navbar" target="_top" href="http://twistedmatrix.com/">Twisted 1.3.0rc1</a>
24
</p></th></tr></table>
28
<table width="100%" cellpadding="0" cellspacing="0">
31
<font size="-1"><b class="breadcrumbs">
32
<a href="twisted.html">Package twisted</a> ::
33
<a href="twisted.protocols.html">Package protocols</a> ::
34
<a href="twisted.protocols.policies.html">Module policies</a> ::
35
Class TimeoutProtocol
38
<td><table cellpadding="0" cellspacing="0">
39
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a> | <a href="twisted.protocols.policies.TimeoutProtocol.html" target="_top">no frames</a>]</font></td></tr>
43
<!-- =========== START OF CLASS DESCRIPTION =========== -->
44
<h2 class="class">Class TimeoutProtocol</h2>
46
<pre class="base-tree">
47
<a href="twisted.internet.protocol.BaseProtocol.html"><code>BaseProtocol</code></a> --+
49
<a href="twisted.internet.protocol.Protocol.html"><code>Protocol</code></a> --+
51
<a href="twisted.protocols.policies.ProtocolWrapper.html"><code>ProtocolWrapper</code></a> --+
53
<b>TimeoutProtocol</b>
58
<p>Protocol that automatically disconnects when the connection is
64
<!-- =========== START OF METHOD SUMMARY =========== -->
65
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
66
<tr bgcolor="#70b0f0" class="summary">
67
<th colspan="2">Method Summary</th></tr>
68
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
69
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class=summary-sig-arg>self</span>,
70
<span class=summary-sig-arg>factory</span>,
71
<span class=summary-sig-arg>wrappedProtocol</span>,
72
<span class=summary-sig-arg>timeoutPeriod</span>)</span></code>
74
Constructor.</td></tr>
75
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
76
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#cancelTimeout" class="summary-sig-name"><code>cancelTimeout</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
78
Cancel the timeout.</td></tr>
79
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
80
<td><code><a name="connectionLost"></a><span class="summary-sig"><span class="summary-sig-name">connectionLost</span>(<span class=summary-sig-arg>self</span>,
81
<span class=summary-sig-arg>reason</span>)</span></code>
83
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
84
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#dataReceived" class="summary-sig-name"><code>dataReceived</code></a>(<span class=summary-sig-arg>self</span>,
85
<span class=summary-sig-arg>data</span>)</span></code>
87
Called whenever data is received.</td></tr>
88
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
89
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#resetTimeout" class="summary-sig-name"><code>resetTimeout</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
91
Reset the timeout, usually because some activity just happened.</td></tr>
92
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
93
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#setTimeout" class="summary-sig-name"><code>setTimeout</code></a>(<span class=summary-sig-arg>self</span>,
94
<span class=summary-sig-arg>timeoutPeriod</span>)</span></code>
96
Set a timeout.</td></tr>
97
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
98
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.TimeoutProtocol.html#timeoutFunc" class="summary-sig-name"><code>timeoutFunc</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
100
This method is called when the timeout is triggered.</td></tr>
101
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
102
<td><code><a name="write"></a><span class="summary-sig"><span class="summary-sig-name">write</span>(<span class=summary-sig-arg>self</span>,
103
<span class=summary-sig-arg>data</span>)</span></code>
105
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
106
<td><code><a name="writeSequence"></a><span class="summary-sig"><span class="summary-sig-name">writeSequence</span>(<span class=summary-sig-arg>self</span>,
107
<span class=summary-sig-arg>seq</span>)</span></code>
109
<tr bgcolor="#e8f0f8" class="group">
110
<th colspan="2"> Inherited from ProtocolWrapper</th></tr>
111
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
112
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#__getattr__" class="summary-sig-name"><code>__getattr__</code></a>(<span class=summary-sig-arg>self</span>,
113
<span class=summary-sig-arg>name</span>)</span></code>
115
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
116
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#connectionMade" class="summary-sig-name"><code>connectionMade</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
118
Called when a connection is made.</td></tr>
119
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
120
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#getHost" class="summary-sig-name"><code>getHost</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
122
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
123
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#getPeer" class="summary-sig-name"><code>getPeer</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
125
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
126
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#loseConnection" class="summary-sig-name"><code>loseConnection</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
128
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
129
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#makeConnection" class="summary-sig-name"><code>makeConnection</code></a>(<span class=summary-sig-arg>self</span>,
130
<span class=summary-sig-arg>transport</span>)</span></code>
132
Make a connection to a transport and a server.</td></tr>
133
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
134
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#registerProducer" class="summary-sig-name"><code>registerProducer</code></a>(<span class=summary-sig-arg>self</span>,
135
<span class=summary-sig-arg>producer</span>,
136
<span class=summary-sig-arg>streaming</span>)</span></code>
138
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
139
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#stopConsuming" class="summary-sig-name"><code>stopConsuming</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
141
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
142
<td><code><span class="summary-sig"><a href="twisted.protocols.policies.ProtocolWrapper.html#unregisterProducer" class="summary-sig-name"><code>unregisterProducer</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
144
<tr bgcolor="#e8f0f8" class="group">
145
<th colspan="2"> Inherited from Protocol</th></tr>
146
<tr><td align="right" valign="top" width="15%"><font size="-1"> </font></td>
147
<td><code><span class="summary-sig"><a href="twisted.internet.protocol.Protocol.html#connectionFailed" class="summary-sig-name"><code>connectionFailed</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
149
(Deprecated)</td></tr>
153
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
154
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
155
<tr bgcolor="#70b0f0" class="summary">
156
<th colspan="2">Class Variable Summary</th></tr>
157
<tr bgcolor="#e8f0f8" class="group">
158
<th colspan="2"> Inherited from ProtocolWrapper</th></tr>
159
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>tuple</code></font></td>
160
<td><b><a href="twisted.protocols.policies.ProtocolWrapper.html#__implements__"><code>__implements__</code></a></b> = <span title="(<class twisted.internet.interfaces.ITransport at 0x8254024>,)"><code>(<class twisted.internet.interfaces.ITr<span class="variable-ellipsis">...</span></code>
162
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
163
<td><b><a href="twisted.protocols.policies.ProtocolWrapper.html#disconnecting"><code>disconnecting</code></a></b> = <span title="0">0 </span></td></tr>
164
<tr bgcolor="#e8f0f8" class="group">
165
<th colspan="2"> Inherited from BaseProtocol</th></tr>
166
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
167
<td><b><a href="twisted.internet.protocol.BaseProtocol.html#connected"><code>connected</code></a></b> = <span title="0">0 </span></td></tr>
168
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
169
<td><b><a href="twisted.internet.protocol.BaseProtocol.html#transport"><code>transport</code></a></b> = <span title="None">None </span></td></tr>
173
<!-- =========== START OF METHOD DETAILS =========== -->
174
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
175
<tr bgcolor="#70b0f0" class="details">
176
<th colspan="2">Method Details</th></tr>
179
<a name="__init__"></a>
180
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
181
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class=sig-arg>self</span>,
182
<span class=sig-arg>factory</span>,
183
<span class=sig-arg>wrappedProtocol</span>,
184
<span class=sig-arg>timeoutPeriod</span>)</span>
185
<br /><i>(Constructor)</i>
189
<dl><dt><b>Parameters:</b></dt>
190
<dd><code><b>factory</b></code> -
191
An <code>IFactory</code>.
192
<dd><code><b>wrappedProtocol</b></code> -
193
A <a href="twisted.internet.protocol.Protocol.html"
194
class="link"><code>Protocol</code></a> to wrapp.
195
<dd><code><b>timeoutPeriod</b></code> -
196
Number of seconds to wait for activity before timing out.
199
<dl><dt><b>Overrides:</b></dt>
200
<dd><a href="twisted.protocols.policies.ProtocolWrapper.html#__init__"><code>twisted.protocols.policies.ProtocolWrapper.__init__</code></a></dd>
205
<a name="cancelTimeout"></a>
206
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
207
<h3><span class="sig"><span class="sig-name">cancelTimeout</span>(<span class=sig-arg>self</span>)</span>
209
<p>Cancel the timeout.</p>
210
If the timeout was already cancelled, this does nothing.
215
<a name="dataReceived"></a>
216
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
217
<h3><span class="sig"><span class="sig-name">dataReceived</span>(<span class=sig-arg>self</span>,
218
<span class=sig-arg>data</span>)</span>
220
<p>Called whenever data is received.</p>
221
Use this method to translate to a higher-level message. Usually,
222
some callback will be made upon the receipt of each complete protocol
225
<dl><dt><b>Parameters:</b></dt>
226
<dd><code><b>data</b></code> -
227
a string of indeterminate length. Please keep in mind that you
228
will probably need to buffer some data, as partial (or multiple)
229
protocol messages may be received! I recommend that unit tests
230
for protocols call through to this method with differing chunk
231
sizes, down to one byte at a time.
234
<dl><dt><b>Overrides:</b></dt>
235
<dd><a href="twisted.protocols.policies.ProtocolWrapper.html#dataReceived"><code>twisted.protocols.policies.ProtocolWrapper.dataReceived</code></a> <i>(inherited documentation)</i>
241
<a name="resetTimeout"></a>
242
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
243
<h3><span class="sig"><span class="sig-name">resetTimeout</span>(<span class=sig-arg>self</span>)</span>
245
Reset the timeout, usually because some activity just happened.
250
<a name="setTimeout"></a>
251
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
252
<h3><span class="sig"><span class="sig-name">setTimeout</span>(<span class=sig-arg>self</span>,
253
<span class=sig-arg>timeoutPeriod</span>=<span class=sig-default>None</span>)</span>
255
<p>Set a timeout.</p>
256
This will cancel any existing timeouts.
258
<dl><dt><b>Parameters:</b></dt>
259
<dd><code><b>timeoutPeriod</b></code> -
260
If not <code>None</code>, change the timeout period.
261
Otherwise, use the existing value.
267
<a name="timeoutFunc"></a>
268
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
269
<h3><span class="sig"><span class="sig-name">timeoutFunc</span>(<span class=sig-arg>self</span>)</span>
271
<p>This method is called when the timeout is triggered.</p>
272
By default it calls <a
273
href="twisted.protocols.policies.ProtocolWrapper.html#loseConnection"
274
class="link"><code>loseConnection</code></a>. Override this if you want
275
something else to happen.
282
<!-- =========== START OF NAVBAR =========== -->
283
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
285
<th class="navbar"> <a class="navbar" href="twisted.html">Home</a> </th>
286
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
287
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
288
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
289
<th class="navbar" align="right" width="100%">
290
<table border="0" cellpadding="0" cellspacing="0">
291
<tr><th class="navbar" align="center">
293
<a class="navbar" target="_top" href="http://twistedmatrix.com/">Twisted 1.3.0rc1</a>
294
</p></th></tr></table>
299
<table border="0" cellpadding="0" cellspacing="0" width="100%">
301
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sat May 15 20:08:02 2004</font></td>
302
<td align="right"><a href="http://epydoc.sourceforge.net"
303
><font size="-2">http://epydoc.sf.net</font></a></td>