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.181 by root, Tue Sep 1 10:40:05 2009 UTC vs.
Revision 1.182 by root, Thu Sep 3 12:35:01 2009 UTC

284In some situations you want as low a delay as possible, which can be 284In some situations you want as low a delay as possible, which can be
285accomplishd by setting this option to a true value. 285accomplishd by setting this option to a true value.
286 286
287The default is your opertaing system's default behaviour (most likely 287The default is your opertaing system's default behaviour (most likely
288enabled), this option explicitly enables or disables it, if possible. 288enabled), this option explicitly enables or disables it, if possible.
289
290=item keepalive => <boolean>
291
292Enables (default disable) the SO_KEEPALIVE option on the stream socket:
293normally, TCP connections have no time-out once established, so TCP
294conenctions, once established, can stay alive forever even when the other
295side has long gone. TCP keepalives are a cheap way to take down long-lived
296TCP connections whent he other side becomes unreachable. While the default
297is OS-dependent, TCP keepalives usually kick in after around two hours,
298and, if the other side doesn't reply, take down the TCP connection some 10
299to 15 minutes later.
300
301It is harmless to specify this option for file handles that do not support
302keepalives, and enabling it on connections that are potentially long-lived
303is usually a good idea.
304
305=item oobinline => <boolean>
306
307BSD majorly fucked up the implementation of TCP urgent data. The result
308is that almost no OS implements TCP according to the specs, and every OS
309implements it slightly differently.
310
311If you want to handle TCP urgent data, then setting this flag gives you
312the most portable way of getting urgent data, by putting it into the
313stream.
289 314
290=item read_size => <bytes> 315=item read_size => <bytes>
291 316
292The default read block size (the amount of bytes this module will 317The default read block size (the amount of bytes this module will
293try to read during each loop iteration, which affects memory 318try 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;
587sub no_delay { 614sub 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
626Enables or disables the C<keepalive> setting (see constructor argument of
627the same name for details).
628
629=cut
630
631sub 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
643Enables or disables the C<oobinline> setting (see constructor argument of
644the same name for details).
645
646=cut
647
648sub 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
660Enables or disables the C<keepalive> setting (see constructor argument of
661the same name for details).
662
663=cut
664
665sub 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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines