ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.155 by root, Mon Jul 20 22:39:57 2009 UTC vs.
Revision 1.158 by root, Fri Jul 24 08:40:35 2009 UTC

69 69
70=over 4 70=over 4
71 71
72=item fh => $filehandle [MANDATORY] 72=item fh => $filehandle [MANDATORY]
73 73
74#=item fh => $filehandle [C<fh> or C<connect> MANDATORY]
75
74The filehandle this L<AnyEvent::Handle> object will operate on. 76The filehandle this L<AnyEvent::Handle> object will operate on.
75
76NOTE: The filehandle will be set to non-blocking mode (using 77NOTE: The filehandle will be set to non-blocking mode (using
77C<AnyEvent::Util::fh_nonblocking>) by the constructor and needs to stay in 78C<AnyEvent::Util::fh_nonblocking>) by the constructor and needs to stay in
78that mode. 79that mode.
80
81#=item connect => [$host, $service]
82#
83# You have to specify either this parameter, or C<connect>, below.
84#Try to connect to the specified host and service (port), using
85#C<AnyEvent::Socket::tcp_connect>.
86#
87#When this
79 88
80=item on_eof => $cb->($handle) 89=item on_eof => $cb->($handle)
81 90
82Set the callback to be called when an end-of-file condition is detected, 91Set the callback to be called when an end-of-file condition is detected,
83i.e. in the case of a socket, when the other side has closed the 92i.e. in the case of a socket, when the other side has closed the
1519 1528
1520Instead of starting TLS negotiation immediately when the AnyEvent::Handle 1529Instead of starting TLS negotiation immediately when the AnyEvent::Handle
1521object is created, you can also do that at a later time by calling 1530object is created, you can also do that at a later time by calling
1522C<starttls>. 1531C<starttls>.
1523 1532
1533Starting TLS is currently an asynchronous operation - when you push some
1534write data and then call C<< ->starttls >> then TLS negotiation will start
1535immediately, after which the queued write data is then sent.
1536
1524The first argument is the same as the C<tls> constructor argument (either 1537The first argument is the same as the C<tls> constructor argument (either
1525C<"connect">, C<"accept"> or an existing Net::SSLeay object). 1538C<"connect">, C<"accept"> or an existing Net::SSLeay object).
1526 1539
1527The second argument is the optional C<AnyEvent::TLS> object that is used 1540The second argument is the optional C<AnyEvent::TLS> object that is used
1528when AnyEvent::Handle has to create its own TLS connection object, or 1541when AnyEvent::Handle has to create its own TLS connection object, or
1552 $ERROR_SYSCALL = Net::SSLeay::ERROR_SYSCALL (); 1565 $ERROR_SYSCALL = Net::SSLeay::ERROR_SYSCALL ();
1553 $ERROR_WANT_READ = Net::SSLeay::ERROR_WANT_READ (); 1566 $ERROR_WANT_READ = Net::SSLeay::ERROR_WANT_READ ();
1554 1567
1555 $ctx ||= $self->{tls_ctx}; 1568 $ctx ||= $self->{tls_ctx};
1556 1569
1570 local $Carp::CarpLevel = 1; # skip ourselves when creating a new context or session
1571
1557 if ("HASH" eq ref $ctx) { 1572 if ("HASH" eq ref $ctx) {
1558 require AnyEvent::TLS; 1573 require AnyEvent::TLS;
1559
1560 local $Carp::CarpLevel = 1; # skip ourselves when creating a new context
1561 1574
1562 if ($ctx->{cache}) { 1575 if ($ctx->{cache}) {
1563 my $key = $ctx+0; 1576 my $key = $ctx+0;
1564 $ctx = $TLS_CACHE{$key} ||= new AnyEvent::TLS %$ctx; 1577 $ctx = $TLS_CACHE{$key} ||= new AnyEvent::TLS %$ctx;
1565 } else { 1578 } else {
1637 1650
1638 &_freetls; 1651 &_freetls;
1639 1652
1640 my $linger = exists $self->{linger} ? $self->{linger} : 3600; 1653 my $linger = exists $self->{linger} ? $self->{linger} : 3600;
1641 1654
1642 if ($linger && length $self->{wbuf}) { 1655 if ($linger && length $self->{wbuf} && $self->{fh}) {
1643 my $fh = delete $self->{fh}; 1656 my $fh = delete $self->{fh};
1644 my $wbuf = delete $self->{wbuf}; 1657 my $wbuf = delete $self->{wbuf};
1645 1658
1646 my @linger; 1659 my @linger;
1647 1660

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines