@@ -95,132 +95,132 @@ any that have been added to the map during asynchronous service) is closed.
95
95
should be added to the list of channels :cfunc: `select `\ ed or
96
96
:cfunc: `poll `\ ed for read and write events.
97
97
98
- Thus, the set of channel events is larger than the basic socket events. The
99
- full set of methods that can be overridden in your subclass follows:
98
+ Thus, the set of channel events is larger than the basic socket events. The
99
+ full set of methods that can be overridden in your subclass follows:
100
100
101
101
102
- .. method :: dispatcher. handle_read()
102
+ .. method :: handle_read()
103
103
104
- Called when the asynchronous loop detects that a :meth: `read ` call on the
105
- channel's socket will succeed.
104
+ Called when the asynchronous loop detects that a :meth: `read ` call on the
105
+ channel's socket will succeed.
106
106
107
107
108
- .. method :: dispatcher. handle_write()
108
+ .. method :: handle_write()
109
109
110
- Called when the asynchronous loop detects that a writable socket can be
111
- written. Often this method will implement the necessary buffering for
112
- performance. For example::
110
+ Called when the asynchronous loop detects that a writable socket can be
111
+ written. Often this method will implement the necessary buffering for
112
+ performance. For example::
113
113
114
- def handle_write(self):
115
- sent = self.send(self.buffer)
116
- self.buffer = self.buffer[sent:]
114
+ def handle_write(self):
115
+ sent = self.send(self.buffer)
116
+ self.buffer = self.buffer[sent:]
117
117
118
118
119
- .. method :: dispatcher. handle_expt()
119
+ .. method :: handle_expt()
120
120
121
- Called when there is out of band (OOB) data for a socket connection. This
122
- will almost never happen, as OOB is tenuously supported and rarely used.
121
+ Called when there is out of band (OOB) data for a socket connection. This
122
+ will almost never happen, as OOB is tenuously supported and rarely used.
123
123
124
124
125
- .. method :: dispatcher. handle_connect()
125
+ .. method :: handle_connect()
126
126
127
- Called when the active opener's socket actually makes a connection. Might
128
- send a "welcome" banner, or initiate a protocol negotiation with the remote
129
- endpoint, for example.
127
+ Called when the active opener's socket actually makes a connection. Might
128
+ send a "welcome" banner, or initiate a protocol negotiation with the
129
+ remote endpoint, for example.
130
130
131
131
132
- .. method :: dispatcher. handle_close()
132
+ .. method :: handle_close()
133
133
134
- Called when the socket is closed.
134
+ Called when the socket is closed.
135
135
136
136
137
- .. method :: dispatcher. handle_error()
137
+ .. method :: handle_error()
138
138
139
- Called when an exception is raised and not otherwise handled. The default
140
- version prints a condensed traceback.
139
+ Called when an exception is raised and not otherwise handled. The default
140
+ version prints a condensed traceback.
141
141
142
142
143
- .. method :: dispatcher. handle_accept()
143
+ .. method :: handle_accept()
144
144
145
- Called on listening channels (passive openers) when a connection can be
146
- established with a new remote endpoint that has issued a :meth: `connect `
147
- call for the local endpoint.
145
+ Called on listening channels (passive openers) when a connection can be
146
+ established with a new remote endpoint that has issued a :meth: `connect `
147
+ call for the local endpoint.
148
148
149
149
150
- .. method :: dispatcher. readable()
150
+ .. method :: readable()
151
151
152
- Called each time around the asynchronous loop to determine whether a
153
- channel's socket should be added to the list on which read events can
154
- occur. The default method simply returns ``True ``, indicating that by
155
- default, all channels will be interested in read events.
152
+ Called each time around the asynchronous loop to determine whether a
153
+ channel's socket should be added to the list on which read events can
154
+ occur. The default method simply returns ``True ``, indicating that by
155
+ default, all channels will be interested in read events.
156
156
157
157
158
- .. method :: dispatcher. writable()
158
+ .. method :: writable()
159
159
160
- Called each time around the asynchronous loop to determine whether a
161
- channel's socket should be added to the list on which write events can
162
- occur. The default method simply returns ``True ``, indicating that by
163
- default, all channels will be interested in write events.
160
+ Called each time around the asynchronous loop to determine whether a
161
+ channel's socket should be added to the list on which write events can
162
+ occur. The default method simply returns ``True ``, indicating that by
163
+ default, all channels will be interested in write events.
164
164
165
- In addition, each channel delegates or extends many of the socket methods.
166
- Most of these are nearly identical to their socket partners.
167
165
166
+ In addition, each channel delegates or extends many of the socket methods.
167
+ Most of these are nearly identical to their socket partners.
168
168
169
- .. method :: dispatcher.create_socket(family, type)
170
169
171
- This is identical to the creation of a normal socket, and will use the same
172
- options for creation. Refer to the :mod: `socket ` documentation for
173
- information on creating sockets.
170
+ .. method :: create_socket(family, type)
174
171
172
+ This is identical to the creation of a normal socket, and will use the
173
+ same options for creation. Refer to the :mod: `socket ` documentation for
174
+ information on creating sockets.
175
175
176
- .. method :: dispatcher.connect(address)
177
176
178
- As with the normal socket object, *address * is a tuple with the first
179
- element the host to connect to, and the second the port number.
177
+ .. method :: connect(address)
180
178
179
+ As with the normal socket object, *address * is a tuple with the first
180
+ element the host to connect to, and the second the port number.
181
181
182
- .. method :: dispatcher.send(data)
183
182
184
- Send * data * to the remote end-point of the socket.
183
+ .. method :: send(data)
185
184
185
+ Send *data * to the remote end-point of the socket.
186
186
187
- .. method :: dispatcher.recv(buffer_size)
188
187
189
- Read at most *buffer_size * bytes from the socket's remote end-point.
190
- An empty string implies that the channel has been closed from the other
191
- end.
188
+ .. method :: recv(buffer_size)
192
189
190
+ Read at most *buffer_size * bytes from the socket's remote end-point. An
191
+ empty string implies that the channel has been closed from the other end.
193
192
194
- .. method :: dispatcher.listen(backlog)
195
193
196
- Listen for connections made to the socket. The *backlog * argument
197
- specifies the maximum number of queued connections and should be at least
198
- 1; the maximum value is system-dependent (usually 5).
194
+ .. method :: listen(backlog)
199
195
196
+ Listen for connections made to the socket. The *backlog * argument
197
+ specifies the maximum number of queued connections and should be at least
198
+ 1; the maximum value is system-dependent (usually 5).
200
199
201
- .. method :: dispatcher.bind(address)
202
200
203
- Bind the socket to *address *. The socket must not already be bound. (The
204
- format of *address * depends on the address family --- see above.) To mark
205
- the socket as re-usable (setting the :const: `SO_REUSEADDR ` option), call
206
- the :class: `dispatcher ` object's :meth: `set_reuse_addr ` method.
201
+ .. method :: bind(address)
207
202
203
+ Bind the socket to *address *. The socket must not already be bound. (The
204
+ format of *address * depends on the address family --- see above.) To mark
205
+ the socket as re-usable (setting the :const: `SO_REUSEADDR ` option), call
206
+ the :class: `dispatcher ` object's :meth: `set_reuse_addr ` method.
208
207
209
- .. method :: dispatcher.accept()
210
208
211
- Accept a connection. The socket must be bound to an address and listening
212
- for connections. The return value is a pair ``(conn, address) `` where
213
- *conn * is a *new * socket object usable to send and receive data on the
214
- connection, and *address * is the address bound to the socket on the other
215
- end of the connection.
209
+ .. method :: accept()
216
210
211
+ Accept a connection. The socket must be bound to an address and listening
212
+ for connections. The return value is a pair ``(conn, address) `` where
213
+ *conn * is a *new * socket object usable to send and receive data on the
214
+ connection, and *address * is the address bound to the socket on the other
215
+ end of the connection.
217
216
218
- .. method :: dispatcher.close()
219
217
220
- Close the socket. All future operations on the socket object will fail.
221
- The remote end-point will receive no more data (after queued data is
222
- flushed). Sockets are automatically closed when they are
223
- garbage-collected.
218
+ .. method :: close()
219
+
220
+ Close the socket. All future operations on the socket object will fail.
221
+ The remote end-point will receive no more data (after queued data is
222
+ flushed). Sockets are automatically closed when they are
223
+ garbage-collected.
224
224
225
225
226
226
.. _asyncore-example :
0 commit comments