--- AnyEvent/lib/AnyEvent/Handle.pm 2008/08/21 18:45:16 1.82 +++ AnyEvent/lib/AnyEvent/Handle.pm 2008/08/21 20:52:39 1.87 @@ -51,6 +51,9 @@ filehandles. For utility functions for doing non-blocking connects and accepts on sockets see L. +The L tutorial contains some well-documented +AnyEvent::Handle examples. + In the following, when the documentation refers to of "bytes" then this means characters. As sysread and syswrite are used for all I/O, their treatment of characters applies to this module as well. @@ -72,8 +75,9 @@ The filehandle this L object will operate on. -NOTE: The filehandle will be set to non-blocking (using -AnyEvent::Util::fh_nonblocking). +NOTE: The filehandle will be set to non-blocking mode (using +C) by the constructor and needs to stay in +that mode. =item on_eof => $cb->($handle) @@ -225,22 +229,23 @@ =item tls => "accept" | "connect" | Net::SSLeay::SSL object -When this parameter is given, it enables TLS (SSL) mode, that means it -will start making tls handshake and will transparently encrypt/decrypt +When this parameter is given, it enables TLS (SSL) mode, that means +AnyEvent will start a TLS handshake and will transparently encrypt/decrypt data. TLS mode requires Net::SSLeay to be installed (it will be loaded automatically when you try to create a TLS handle). -For the TLS server side, use C, and for the TLS client side of a -connection, use C mode. +Unlike TCP, TLS has a server and client side: for the TLS server side, use +C, and for the TLS client side of a connection, use C +mode. You can also provide your own TLS connection object, but you have to make sure that you call either C or C on it before you pass it to AnyEvent::Handle. -See the C method if you need to start TLS negotiation later. +See the C method for when need to start TLS negotiation later. =item tls_ctx => $ssl_ctx @@ -253,7 +258,8 @@ This is the json coder object used by the C read and write types. If you don't supply it, then AnyEvent::Handle will create and use a -suitable one, which will write and expect UTF-8 encoded JSON texts. +suitable one (on demand), which will write and expect UTF-8 encoded JSON +texts. Note that you are responsible to depend on the JSON module if you want to use this functionality, as AnyEvent does not have a dependency itself. @@ -262,7 +268,8 @@ =item filter_w => $cb -These exist, but are undocumented at this time. +These exist, but are undocumented at this time. (They are used internally +by the TLS code). =back @@ -1363,6 +1370,12 @@ # (unfortunately, we have to hardcode constants because the abysmally misdesigned # and mismaintained ssleay-module doesn't even offer them). # http://www.mail-archive.com/openssl-dev@openssl.org/msg22420.html + # + # in short: this is a mess. + # + # note that we do not try to kepe the length constant between writes as we are required to do. + # we assume that most (but not all) of this insanity only applies to non-blocking cases, + # and we drive openssl fully in blocking mode here. Net::SSLeay::CTX_set_mode ($self->{tls}, (eval { local $SIG{__DIE__}; Net::SSLeay::MODE_ENABLE_PARTIAL_WRITE () } || 1) | (eval { local $SIG{__DIE__}; Net::SSLeay::MODE_ACCEPT_MOVING_WRITE_BUFFER () } || 2));