PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|AnyEvent|Handle.pm =

page 3 of 15



You can also provide your own TLS connection object, but you have
to make sure that you call either C<Net::SSLeay::set_connect_state>
or C<Net::SSLeay::set_accept_state> on it before you pass it to
AnyEvent::Handle.

See the C<starttls> method if you need to start TLs negotiation later.

=item tls_ctx => $ssl_ctx

Use the given Net::SSLeay::CTX object to create the new TLS connection
(unless a connection object was specified directly). If this parameter is
missing, then AnyEvent::Handle will use C<AnyEvent::Handle::TLS_CTX>.

=item json => JSON or JSON::XS object

This is the json coder object used by the C<json> read and write types.

If you don't supply it, then AnyEvent::Handle will create and use a
suitable one, which will write and expect UTF-8 encoded JSON texts.

Note that you are responsible to depend on the JSON module if you want to
use this functionality, as AnyEvent does not have a dependency itself.

=item filter_r => $cb

=item filter_w => $cb

These exist, but are undocumented at this time.

=back

=cut

sub new {
   my $class = shift;

   my $self = bless { @_ }, $class;

   $self->{fh} or Carp::croak "mandatory argument fh is missing";

   AnyEvent::Util::fh_nonblocking $self->{fh}, 1;

   if ($self->{tls}) {
      require Net::SSLeay;
      $self->starttls (delete $self->{tls}, delete $self->{tls_ctx});
   }

   $self->{_activity} = AnyEvent->now;
   $self->_timeout;

   $self->on_drain (delete $self->{on_drain}) if $self->{on_drain};

   $self->start_read
      if $self->{on_read};

   $self
}

sub _shutdown {
   my ($self) = @_;

   delete $self->{_tw};
   delete $self->{_rw};
   delete $self->{_ww};
   delete $self->{fh};

   $self->stoptls;
}

sub _error {
   my ($self, $errno, $fatal) = @_;

   $self->_shutdown
      if $fatal;

   $! = $errno;

   if ($self->{on_error}) {
      $self->{on_error}($self, $fatal);
   } else {
      Carp::croak "AnyEvent::Handle uncaught error: $!";
   }
}

=item $fh = $handle->fh

This method returns the file handle of the L<AnyEvent::Handle> object.

=cut

sub fh { $_[0]{fh} }

=item $handle->on_error ($cb)

Replace the current C<on_error> callback (see the C<on_error> constructor argument).

=cut

sub on_error {
   $_[0]{on_error} = $_[1];
=3=

1|2| < PREV = PAGE 3 = NEXT > |4|5|6|7|8|9|10|11|12.15

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00601792 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)