| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 :mod:`asyncore` --- Asynchronous socket handler | 2 :mod:`asyncore` --- Asynchronous socket handler |
| 3 =============================================== | 3 =============================================== |
| 4 | 4 |
| 5 .. module:: asyncore | 5 .. module:: asyncore |
| 6 :synopsis: A base class for developing asynchronous socket handling | 6 :synopsis: A base class for developing asynchronous socket handling |
| 7 services. | 7 services. |
| 8 .. moduleauthor:: Sam Rushing <rushing@nightmare.com> | 8 .. moduleauthor:: Sam Rushing <rushing@nightmare.com> |
| 9 .. sectionauthor:: Christopher Petrilli <petrilli@amber.org> | 9 .. sectionauthor:: Christopher Petrilli <petrilli@amber.org> |
| 10 .. sectionauthor:: Steve Holden <sholden@holdenweb.com> | 10 .. sectionauthor:: Steve Holden <sholden@holdenweb.com> |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 end of the connection. | 215 end of the connection. |
| 216 | 216 |
| 217 | 217 |
| 218 .. method:: close() | 218 .. method:: close() |
| 219 | 219 |
| 220 Close the socket. All future operations on the socket object will fail. | 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 | 221 The remote end-point will receive no more data (after queued data is |
| 222 flushed). Sockets are automatically closed when they are | 222 flushed). Sockets are automatically closed when they are |
| 223 garbage-collected. | 223 garbage-collected. |
| 224 | 224 |
| 225 .. class:: file_dispatcher() | |
| 226 A file_dispatcher takes a file descriptor or file object along with an optiona l | |
|
GvR
2008/05/05 22:02:22
Mind keeping the line length under 80 chars?
josiah.carlson
2008/05/21 19:09:43
On 2008/05/05 22:02:22, GvR wrote:
> Mind keeping
| |
| 227 map argument and wraps it for use with the :cfunc:`poll`\ or :cfunc:`loop`\ | |
| 228 functions. If provided a file object or anything with a :cfunc:`fileno`\ | |
| 229 method, that method will be called and passed to the :class:`file_wrapper` | |
| 230 constructor. | |
| 231 Availability: UNIX | |
| 232 | |
| 233 .. class::file_wrapper() | |
| 234 A file_wrapper takes an integer file descriptor and calls os.dup() to duplicat e | |
| 235 the handle so that the original handle may be closed independently of the | |
| 236 file_wrapper. This class implements sufficient methods to emulate a socket fo r | |
| 237 use by the file_dispatcher class. | |
| 238 Availability: UNIX | |
| 225 | 239 |
| 226 .. _asyncore-example: | 240 .. _asyncore-example: |
| 227 | 241 |
| 228 asyncore Example basic HTTP client | 242 asyncore Example basic HTTP client |
| 229 ---------------------------------- | 243 ---------------------------------- |
| 230 | 244 |
| 231 Here is a very basic HTTP client that uses the :class:`dispatcher` class to | 245 Here is a very basic HTTP client that uses the :class:`dispatcher` class to |
| 232 implement its socket handling:: | 246 implement its socket handling:: |
| 233 | 247 |
| 234 import asyncore, socket | 248 import asyncore, socket |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 253 def writable(self): | 267 def writable(self): |
| 254 return (len(self.buffer) > 0) | 268 return (len(self.buffer) > 0) |
| 255 | 269 |
| 256 def handle_write(self): | 270 def handle_write(self): |
| 257 sent = self.send(self.buffer) | 271 sent = self.send(self.buffer) |
| 258 self.buffer = self.buffer[sent:] | 272 self.buffer = self.buffer[sent:] |
| 259 | 273 |
| 260 c = http_client('www.python.org', '/') | 274 c = http_client('www.python.org', '/') |
| 261 | 275 |
| 262 asyncore.loop() | 276 asyncore.loop() |
| OLD | NEW |