… | |
… | |
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 | |
74 | The filehandle this L<AnyEvent::Handle> object will operate on. |
76 | The filehandle this L<AnyEvent::Handle> object will operate on. |
75 | |
|
|
76 | NOTE: The filehandle will be set to non-blocking mode (using |
77 | NOTE: The filehandle will be set to non-blocking mode (using |
77 | C<AnyEvent::Util::fh_nonblocking>) by the constructor and needs to stay in |
78 | C<AnyEvent::Util::fh_nonblocking>) by the constructor and needs to stay in |
78 | that mode. |
79 | that 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 | |
82 | Set the callback to be called when an end-of-file condition is detected, |
91 | Set the callback to be called when an end-of-file condition is detected, |
83 | i.e. in the case of a socket, when the other side has closed the |
92 | i.e. in the case of a socket, when the other side has closed the |
… | |
… | |
1519 | |
1528 | |
1520 | Instead of starting TLS negotiation immediately when the AnyEvent::Handle |
1529 | Instead of starting TLS negotiation immediately when the AnyEvent::Handle |
1521 | object is created, you can also do that at a later time by calling |
1530 | object is created, you can also do that at a later time by calling |
1522 | C<starttls>. |
1531 | C<starttls>. |
1523 | |
1532 | |
|
|
1533 | Starting TLS is currently an asynchronous operation - when you push some |
|
|
1534 | write data and then call C<< ->starttls >> then TLS negotiation will start |
|
|
1535 | immediately, after which the queued write data is then sent. |
|
|
1536 | |
1524 | The first argument is the same as the C<tls> constructor argument (either |
1537 | The first argument is the same as the C<tls> constructor argument (either |
1525 | C<"connect">, C<"accept"> or an existing Net::SSLeay object). |
1538 | C<"connect">, C<"accept"> or an existing Net::SSLeay object). |
1526 | |
1539 | |
1527 | The second argument is the optional C<AnyEvent::TLS> object that is used |
1540 | The second argument is the optional C<AnyEvent::TLS> object that is used |
1528 | when AnyEvent::Handle has to create its own TLS connection object, or |
1541 | when 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 | |