… | |
… | |
284 | In some situations you want as low a delay as possible, which can be |
284 | In some situations you want as low a delay as possible, which can be |
285 | accomplishd by setting this option to a true value. |
285 | accomplishd by setting this option to a true value. |
286 | |
286 | |
287 | The default is your opertaing system's default behaviour (most likely |
287 | The default is your opertaing system's default behaviour (most likely |
288 | enabled), this option explicitly enables or disables it, if possible. |
288 | enabled), this option explicitly enables or disables it, if possible. |
|
|
289 | |
|
|
290 | =item keepalive => <boolean> |
|
|
291 | |
|
|
292 | Enables (default disable) the SO_KEEPALIVE option on the stream socket: |
|
|
293 | normally, TCP connections have no time-out once established, so TCP |
|
|
294 | conenctions, once established, can stay alive forever even when the other |
|
|
295 | side has long gone. TCP keepalives are a cheap way to take down long-lived |
|
|
296 | TCP connections whent he other side becomes unreachable. While the default |
|
|
297 | is OS-dependent, TCP keepalives usually kick in after around two hours, |
|
|
298 | and, if the other side doesn't reply, take down the TCP connection some 10 |
|
|
299 | to 15 minutes later. |
|
|
300 | |
|
|
301 | It is harmless to specify this option for file handles that do not support |
|
|
302 | keepalives, and enabling it on connections that are potentially long-lived |
|
|
303 | is usually a good idea. |
|
|
304 | |
|
|
305 | =item oobinline => <boolean> |
|
|
306 | |
|
|
307 | BSD majorly fucked up the implementation of TCP urgent data. The result |
|
|
308 | is that almost no OS implements TCP according to the specs, and every OS |
|
|
309 | implements it slightly differently. |
|
|
310 | |
|
|
311 | If you want to handle TCP urgent data, then setting this flag gives you |
|
|
312 | the most portable way of getting urgent data, by putting it into the |
|
|
313 | stream. |
289 | |
314 | |
290 | =item read_size => <bytes> |
315 | =item read_size => <bytes> |
291 | |
316 | |
292 | The default read block size (the amount of bytes this module will |
317 | The default read block size (the amount of bytes this module will |
293 | try to read during each loop iteration, which affects memory |
318 | try to read during each loop iteration, which affects memory |
… | |
… | |
490 | |
515 | |
491 | $self->{_activity} = |
516 | $self->{_activity} = |
492 | $self->{_ractivity} = |
517 | $self->{_ractivity} = |
493 | $self->{_wactivity} = AE::now; |
518 | $self->{_wactivity} = AE::now; |
494 | |
519 | |
495 | $self->timeout (delete $self->{timeout} ) if $self->{timeout}; |
520 | $self->timeout (delete $self->{timeout} ) if $self->{timeout}; |
496 | $self->rtimeout (delete $self->{rtimeout}) if $self->{rtimeout}; |
521 | $self->rtimeout (delete $self->{rtimeout} ) if $self->{rtimeout}; |
497 | $self->wtimeout (delete $self->{wtimeout}) if $self->{wtimeout}; |
522 | $self->wtimeout (delete $self->{wtimeout} ) if $self->{wtimeout}; |
498 | |
523 | |
499 | $self->no_delay (delete $self->{no_delay}) if exists $self->{no_delay}; |
524 | $self->no_delay (delete $self->{no_delay} ) if exists $self->{no_delay}; |
|
|
525 | $self->keepalive (delete $self->{keepalive}) if exists $self->{keepalive}; |
|
|
526 | $self->oobinline (delete $self->{oobinline}) if exists $self->{oobinline}; |
500 | |
527 | |
501 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}) |
528 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}) |
502 | if $self->{tls}; |
529 | if $self->{tls}; |
503 | |
530 | |
504 | $self->on_drain (delete $self->{on_drain}) if $self->{on_drain}; |
531 | $self->on_drain (delete $self->{on_drain}) if $self->{on_drain}; |
505 | |
532 | |
506 | $self->start_read |
533 | $self->start_read |
507 | if $self->{on_read} || @{ $self->{_queue} }; |
534 | if $self->{on_read} || @{ $self->{_queue} }; |
508 | |
535 | |
509 | $self->_drain_wbuf; |
536 | $self->_drain_wbuf; |
… | |
… | |
587 | sub no_delay { |
614 | sub no_delay { |
588 | $_[0]{no_delay} = $_[1]; |
615 | $_[0]{no_delay} = $_[1]; |
589 | |
616 | |
590 | eval { |
617 | eval { |
591 | local $SIG{__DIE__}; |
618 | local $SIG{__DIE__}; |
592 | setsockopt $_[0]{fh}, &Socket::IPPROTO_TCP, &Socket::TCP_NODELAY, int $_[1] |
619 | setsockopt $_[0]{fh}, Socket::IPPROTO_TCP (), Socket::TCP_NODELAY (), int $_[1] |
|
|
620 | if $_[0]{fh}; |
|
|
621 | }; |
|
|
622 | } |
|
|
623 | |
|
|
624 | =item $handle->keepalive ($boolean) |
|
|
625 | |
|
|
626 | Enables or disables the C<keepalive> setting (see constructor argument of |
|
|
627 | the same name for details). |
|
|
628 | |
|
|
629 | =cut |
|
|
630 | |
|
|
631 | sub keepalive { |
|
|
632 | $_[0]{keepalive} = $_[1]; |
|
|
633 | |
|
|
634 | eval { |
|
|
635 | local $SIG{__DIE__}; |
|
|
636 | setsockopt $_[0]{fh}, Socket::SOL_SOCKET (), Socket::SO_KEEPALIVE (), int $_[1] |
|
|
637 | if $_[0]{fh}; |
|
|
638 | }; |
|
|
639 | } |
|
|
640 | |
|
|
641 | =item $handle->oobinline ($boolean) |
|
|
642 | |
|
|
643 | Enables or disables the C<oobinline> setting (see constructor argument of |
|
|
644 | the same name for details). |
|
|
645 | |
|
|
646 | =cut |
|
|
647 | |
|
|
648 | sub oobinline { |
|
|
649 | $_[0]{oobinline} = $_[1]; |
|
|
650 | |
|
|
651 | eval { |
|
|
652 | local $SIG{__DIE__}; |
|
|
653 | setsockopt $_[0]{fh}, Socket::SOL_SOCKET (), Socket::SO_OOBINLINE (), int $_[1] |
|
|
654 | if $_[0]{fh}; |
|
|
655 | }; |
|
|
656 | } |
|
|
657 | |
|
|
658 | =item $handle->keepalive ($boolean) |
|
|
659 | |
|
|
660 | Enables or disables the C<keepalive> setting (see constructor argument of |
|
|
661 | the same name for details). |
|
|
662 | |
|
|
663 | =cut |
|
|
664 | |
|
|
665 | sub keepalive { |
|
|
666 | $_[0]{keepalive} = $_[1]; |
|
|
667 | |
|
|
668 | eval { |
|
|
669 | local $SIG{__DIE__}; |
|
|
670 | setsockopt $_[0]{fh}, Socket::SOL_SOCKET (), Socket::SO_KEEPALIVE (), int $_[1] |
593 | if $_[0]{fh}; |
671 | if $_[0]{fh}; |
594 | }; |
672 | }; |
595 | } |
673 | } |
596 | |
674 | |
597 | =item $handle->on_starttls ($cb) |
675 | =item $handle->on_starttls ($cb) |