… | |
… | |
128 | =item on_connect => $cb->($handle, $host, $port, $retry->()) |
128 | =item on_connect => $cb->($handle, $host, $port, $retry->()) |
129 | |
129 | |
130 | This callback is called when a connection has been successfully established. |
130 | This callback is called when a connection has been successfully established. |
131 | |
131 | |
132 | The peer's numeric host and port (the socket peername) are passed as |
132 | The peer's numeric host and port (the socket peername) are passed as |
133 | parameters, together with a retry callback. |
133 | parameters, together with a retry callback. At the time it is called the |
|
|
134 | read and write queues, EOF status, TLS status and similar properties of |
|
|
135 | the handle will have been reset. |
134 | |
136 | |
|
|
137 | It is not allowed to use the read or write queues while the handle object |
|
|
138 | is connecting. |
|
|
139 | |
135 | If, for some reason, the handle is not acceptable, calling C<$retry> |
140 | If, for some reason, the handle is not acceptable, calling C<$retry> will |
136 | will continue with the next connection target (in case of multi-homed |
141 | continue with the next connection target (in case of multi-homed hosts or |
137 | hosts or SRV records there can be multiple connection endpoints). At the |
142 | SRV records there can be multiple connection endpoints). The C<$retry> |
138 | time it is called the read and write queues, eof status, tls status and |
143 | callback can be invoked after the connect callback returns, i.e. one can |
139 | similar properties of the handle will have been reset. |
144 | start a handshake and then decide to retry with the next host if the |
|
|
145 | handshake fails. |
140 | |
146 | |
141 | In most cases, you should ignore the C<$retry> parameter. |
147 | In most cases, you should ignore the C<$retry> parameter. |
142 | |
148 | |
143 | =item on_connect_error => $cb->($handle, $message) |
149 | =item on_connect_error => $cb->($handle, $message) |
144 | |
150 | |
… | |
… | |
224 | If an EOF condition has been detected but no C<on_eof> callback has been |
230 | If an EOF condition has been detected but no C<on_eof> callback has been |
225 | set, then a fatal error will be raised with C<$!> set to <0>. |
231 | set, then a fatal error will be raised with C<$!> set to <0>. |
226 | |
232 | |
227 | =item on_drain => $cb->($handle) |
233 | =item on_drain => $cb->($handle) |
228 | |
234 | |
229 | This sets the callback that is called when the write buffer becomes empty |
235 | This sets the callback that is called once when the write buffer becomes |
230 | (or immediately if the buffer is empty already). |
236 | empty (and immediately when the handle object is created). |
231 | |
237 | |
232 | To append to the write buffer, use the C<< ->push_write >> method. |
238 | To append to the write buffer, use the C<< ->push_write >> method. |
233 | |
239 | |
234 | This callback is useful when you don't want to put all of your write data |
240 | This callback is useful when you don't want to put all of your write data |
235 | into the queue at once, for example, when you want to write the contents |
241 | into the queue at once, for example, when you want to write the contents |
… | |
… | |
880 | |
886 | |
881 | The write queue is very simple: you can add data to its end, and |
887 | The write queue is very simple: you can add data to its end, and |
882 | AnyEvent::Handle will automatically try to get rid of it for you. |
888 | AnyEvent::Handle will automatically try to get rid of it for you. |
883 | |
889 | |
884 | When data could be written and the write buffer is shorter then the low |
890 | When data could be written and the write buffer is shorter then the low |
885 | water mark, the C<on_drain> callback will be invoked. |
891 | water mark, the C<on_drain> callback will be invoked once. |
886 | |
892 | |
887 | =over 4 |
893 | =over 4 |
888 | |
894 | |
889 | =item $handle->on_drain ($cb) |
895 | =item $handle->on_drain ($cb) |
890 | |
896 | |
… | |
… | |
1476 | if (@_ < 3) { |
1482 | if (@_ < 3) { |
1477 | # this is more than twice as fast as the generic code below |
1483 | # this is more than twice as fast as the generic code below |
1478 | sub { |
1484 | sub { |
1479 | $_[0]{rbuf} =~ s/^([^\015\012]*)(\015?\012)// or return; |
1485 | $_[0]{rbuf} =~ s/^([^\015\012]*)(\015?\012)// or return; |
1480 | |
1486 | |
1481 | $cb->($_[0], $1, $2); |
1487 | $cb->($_[0], "$1", "$2"); |
1482 | 1 |
1488 | 1 |
1483 | } |
1489 | } |
1484 | } else { |
1490 | } else { |
1485 | $eol = quotemeta $eol unless ref $eol; |
1491 | $eol = quotemeta $eol unless ref $eol; |
1486 | $eol = qr|^(.*?)($eol)|s; |
1492 | $eol = qr|^(.*?)($eol)|s; |
1487 | |
1493 | |
1488 | sub { |
1494 | sub { |
1489 | $_[0]{rbuf} =~ s/$eol// or return; |
1495 | $_[0]{rbuf} =~ s/$eol// or return; |
1490 | |
1496 | |
1491 | $cb->($_[0], $1, $2); |
1497 | $cb->($_[0], "$1", "$2"); |
1492 | 1 |
1498 | 1 |
1493 | } |
1499 | } |
1494 | } |
1500 | } |
1495 | }; |
1501 | }; |
1496 | |
1502 | |
… | |
… | |
1792 | some readings of the the SSL/TLS specifications basically require this |
1798 | some readings of the the SSL/TLS specifications basically require this |
1793 | attack to be working, as SSL/TLS implementations might stall sending data |
1799 | attack to be working, as SSL/TLS implementations might stall sending data |
1794 | during a rehandshake. |
1800 | during a rehandshake. |
1795 | |
1801 | |
1796 | As a guideline, during the initial handshake, you should not stop reading, |
1802 | As a guideline, during the initial handshake, you should not stop reading, |
1797 | and as a client, it might cause problems, depending on your applciation. |
1803 | and as a client, it might cause problems, depending on your application. |
1798 | |
1804 | |
1799 | =cut |
1805 | =cut |
1800 | |
1806 | |
1801 | sub stop_read { |
1807 | sub stop_read { |
1802 | my ($self) = @_; |
1808 | my ($self) = @_; |