… | |
… | |
49 | |
49 | |
50 | This module is a helper module to make it easier to do event-based I/O on |
50 | This module is a helper module to make it easier to do event-based I/O on |
51 | filehandles. For utility functions for doing non-blocking connects and accepts |
51 | filehandles. For utility functions for doing non-blocking connects and accepts |
52 | on sockets see L<AnyEvent::Util>. |
52 | on sockets see L<AnyEvent::Util>. |
53 | |
53 | |
|
|
54 | The L<AnyEvent::Intro> tutorial contains some well-documented |
|
|
55 | AnyEvent::Handle examples. |
|
|
56 | |
54 | In the following, when the documentation refers to of "bytes" then this |
57 | In the following, when the documentation refers to of "bytes" then this |
55 | means characters. As sysread and syswrite are used for all I/O, their |
58 | means characters. As sysread and syswrite are used for all I/O, their |
56 | treatment of characters applies to this module as well. |
59 | treatment of characters applies to this module as well. |
57 | |
60 | |
58 | All callbacks will be invoked with the handle object as their first |
61 | All callbacks will be invoked with the handle object as their first |
… | |
… | |
70 | |
73 | |
71 | =item fh => $filehandle [MANDATORY] |
74 | =item fh => $filehandle [MANDATORY] |
72 | |
75 | |
73 | The filehandle this L<AnyEvent::Handle> object will operate on. |
76 | The filehandle this L<AnyEvent::Handle> object will operate on. |
74 | |
77 | |
75 | NOTE: The filehandle will be set to non-blocking (using |
78 | NOTE: The filehandle will be set to non-blocking mode (using |
76 | AnyEvent::Util::fh_nonblocking). |
79 | C<AnyEvent::Util::fh_nonblocking>) by the constructor and needs to stay in |
|
|
80 | that mode. |
77 | |
81 | |
78 | =item on_eof => $cb->($handle) |
82 | =item on_eof => $cb->($handle) |
79 | |
83 | |
80 | Set the callback to be called when an end-of-file condition is detected, |
84 | Set the callback to be called when an end-of-file condition is detected, |
81 | i.e. in the case of a socket, when the other side has closed the |
85 | i.e. in the case of a socket, when the other side has closed the |
… | |
… | |
223 | This will not work for partial TLS data that could not yet been |
227 | This will not work for partial TLS data that could not yet been |
224 | encoded. This data will be lost. |
228 | encoded. This data will be lost. |
225 | |
229 | |
226 | =item tls => "accept" | "connect" | Net::SSLeay::SSL object |
230 | =item tls => "accept" | "connect" | Net::SSLeay::SSL object |
227 | |
231 | |
228 | When this parameter is given, it enables TLS (SSL) mode, that means it |
232 | When this parameter is given, it enables TLS (SSL) mode, that means |
229 | will start making tls handshake and will transparently encrypt/decrypt |
233 | AnyEvent will start a TLS handshake and will transparently encrypt/decrypt |
230 | data. |
234 | data. |
231 | |
235 | |
232 | TLS mode requires Net::SSLeay to be installed (it will be loaded |
236 | TLS mode requires Net::SSLeay to be installed (it will be loaded |
233 | automatically when you try to create a TLS handle). |
237 | automatically when you try to create a TLS handle). |
234 | |
238 | |
235 | For the TLS server side, use C<accept>, and for the TLS client side of a |
239 | Unlike TCP, TLS has a server and client side: for the TLS server side, use |
236 | connection, use C<connect> mode. |
240 | C<accept>, and for the TLS client side of a connection, use C<connect> |
|
|
241 | mode. |
237 | |
242 | |
238 | You can also provide your own TLS connection object, but you have |
243 | You can also provide your own TLS connection object, but you have |
239 | to make sure that you call either C<Net::SSLeay::set_connect_state> |
244 | to make sure that you call either C<Net::SSLeay::set_connect_state> |
240 | or C<Net::SSLeay::set_accept_state> on it before you pass it to |
245 | or C<Net::SSLeay::set_accept_state> on it before you pass it to |
241 | AnyEvent::Handle. |
246 | AnyEvent::Handle. |
242 | |
247 | |
243 | See the C<starttls> method if you need to start TLS negotiation later. |
248 | See the C<starttls> method for when need to start TLS negotiation later. |
244 | |
249 | |
245 | =item tls_ctx => $ssl_ctx |
250 | =item tls_ctx => $ssl_ctx |
246 | |
251 | |
247 | Use the given Net::SSLeay::CTX object to create the new TLS connection |
252 | Use the given Net::SSLeay::CTX object to create the new TLS connection |
248 | (unless a connection object was specified directly). If this parameter is |
253 | (unless a connection object was specified directly). If this parameter is |
… | |
… | |
251 | =item json => JSON or JSON::XS object |
256 | =item json => JSON or JSON::XS object |
252 | |
257 | |
253 | This is the json coder object used by the C<json> read and write types. |
258 | This is the json coder object used by the C<json> read and write types. |
254 | |
259 | |
255 | If you don't supply it, then AnyEvent::Handle will create and use a |
260 | If you don't supply it, then AnyEvent::Handle will create and use a |
256 | suitable one, which will write and expect UTF-8 encoded JSON texts. |
261 | suitable one (on demand), which will write and expect UTF-8 encoded JSON |
|
|
262 | texts. |
257 | |
263 | |
258 | Note that you are responsible to depend on the JSON module if you want to |
264 | Note that you are responsible to depend on the JSON module if you want to |
259 | use this functionality, as AnyEvent does not have a dependency itself. |
265 | use this functionality, as AnyEvent does not have a dependency itself. |
260 | |
266 | |
261 | =item filter_r => $cb |
267 | =item filter_r => $cb |