… | |
… | |
58 | 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 |
59 | treatment of characters applies to this module as well. |
59 | treatment of characters applies to this module as well. |
60 | |
60 | |
61 | 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 |
62 | argument. |
62 | argument. |
63 | |
|
|
64 | =head2 SIGPIPE is not handled by this module |
|
|
65 | |
|
|
66 | SIGPIPE is not handled by this module, so one of the practical |
|
|
67 | requirements of using it is to ignore SIGPIPE (C<$SIG{PIPE} = |
|
|
68 | 'IGNORE'>). At least, this is highly recommend in a networked program: If |
|
|
69 | you use AnyEvent::Handle in a filter program (like sort), exiting on |
|
|
70 | SIGPIPE is probably the right thing to do. |
|
|
71 | |
63 | |
72 | =head1 METHODS |
64 | =head1 METHODS |
73 | |
65 | |
74 | =over 4 |
66 | =over 4 |
75 | |
67 | |
… | |
… | |
1478 | @linger = (); |
1470 | @linger = (); |
1479 | }); |
1471 | }); |
1480 | } |
1472 | } |
1481 | } |
1473 | } |
1482 | |
1474 | |
|
|
1475 | =item $handle->destroy |
|
|
1476 | |
|
|
1477 | Shut's down the handle object as much as possible - this call ensures that |
|
|
1478 | no further callbacks will be invoked and resources will be freed as much |
|
|
1479 | as possible. You must not call any methods on the object afterwards. |
|
|
1480 | |
|
|
1481 | The handle might still linger in the background and write out remaining |
|
|
1482 | data, as specified by the C<linger> option, however. |
|
|
1483 | |
|
|
1484 | =cut |
|
|
1485 | |
|
|
1486 | sub destroy { |
|
|
1487 | my ($self) = @_; |
|
|
1488 | |
|
|
1489 | $self->DESTROY; |
|
|
1490 | %$self = (); |
|
|
1491 | } |
|
|
1492 | |
1483 | =item AnyEvent::Handle::TLS_CTX |
1493 | =item AnyEvent::Handle::TLS_CTX |
1484 | |
1494 | |
1485 | This function creates and returns the Net::SSLeay::CTX object used by |
1495 | This function creates and returns the Net::SSLeay::CTX object used by |
1486 | default for TLS mode. |
1496 | default for TLS mode. |
1487 | |
1497 | |
… | |
… | |
1558 | $handle->on_drain (sub { |
1568 | $handle->on_drain (sub { |
1559 | warn "all data submitted to the kernel\n"; |
1569 | warn "all data submitted to the kernel\n"; |
1560 | undef $handle; |
1570 | undef $handle; |
1561 | }); |
1571 | }); |
1562 | |
1572 | |
|
|
1573 | =item I get different callback invocations in TLS mode/Why can't I pause |
|
|
1574 | reading? |
|
|
1575 | |
|
|
1576 | Unlike, say, TCP, TLS conenctions do not consist of two independent |
|
|
1577 | communication channels, one for each direction. Or put differently. the |
|
|
1578 | read and write directions are not independent of each other: you cannot |
|
|
1579 | write data unless you are also prepared to read, and vice versa. |
|
|
1580 | |
|
|
1581 | This can mean than, in TLS mode, you might get C<on_error> or C<on_eof> |
|
|
1582 | callback invocations when you are not expecting any read data - the reason |
|
|
1583 | is that AnyEvent::Handle always reads in TLS mode. |
|
|
1584 | |
|
|
1585 | During the connection, you have to make sure that you always have a |
|
|
1586 | non-empty read-queue, or an C<on_read> watcher. At the end of the |
|
|
1587 | connection (or when you no longer want to use it) you can call the |
|
|
1588 | C<destroy> method. |
|
|
1589 | |
1563 | =back |
1590 | =back |
1564 | |
1591 | |
1565 | |
1592 | |
1566 | =head1 SUBCLASSING AnyEvent::Handle |
1593 | =head1 SUBCLASSING AnyEvent::Handle |
1567 | |
1594 | |