I am pleased to announce AnyEvent 4.0

Why the major version bump?

   Lots of functionality has been added (and thus some bugs are expected),
   although the event core is still compatible to earlier versions and AnyEvent
   is still pure-perl without any (hard) dependencies on any XS modules.

So whats new?

   Apart from a number of bugfixes, the AnyEvent::Socket module has been
   added. It contains a lot of utility functions to handle IPv4 and IPv6
   addresses and tcp connections in a 100% non-blocking way. It supports SRV
   record lookups.

   To make the 100% non-blocking a reality, AnyEvent::Socket uses
   AnyEvent::DNS, a fully asynchronous stub resolver capable of making tens
   of thousands of DNS requests/second, with TCP and EDNS0 support.

   And if you have Net::SSLeay installed, then AnyEvent::Handle can
   transparently manage TLS/SSL connections, too.

   On the microshit windows side, AnyEvent now tries very hard to avoid
   the freeze in the testsuite on broken perls (with reduced functionality,
   but resolver and socket code works fine there, too).

   The distro should hit the CPAN mirrors in a few hours. Documentation
   can be found via its homepage, http://software.schmorp.de/pkg/AnyEvent

Example:

   This (pseudo-) code snippet connects to jabber server, by querying any SRV 
records
   that might exist and connecting to the resulting addresses in turn -
   regardless of wether the server uses ip version 4 or ip version 6 (or
   both):

      AnyEvent::Socket::tcp_connect "jabber.ietf.org", "xmpp-client",
         sub {
            my ($fh) = @_
               or die "connect: $!";

            my $handle;
            $handle = new AnyEvent::Handle
               fh => $fh,
               on_eof => sub {
                  undef $handle; # destroy handle on eof
               },
            ;

            # etc..
            # when server and client handshake a SSL connection, one can simply
            # call $handle->starttls ("connect") to start ssl negotiation.

            # push some writes or soem reads here, or set some callbacks
         };

   This (non-pseudo-code) code snippet asynchronously connects to
   https://www.google.de and makes a simple GET request:

      use AnyEvent::Impl::Perl; # use portable perl event loop
      use AnyEvent::Handle;
      use AnyEvent::Socket;

      my $cv = AnyEvent->condvar;

      AnyEvent::Socket::tcp_connect "www.google.de", 443,
         sub {
            my ($fh) = @_
               or die "connect: $!";

            my $handle; # avoid direct assignment so on_eof has it in scope.
            $handle = new AnyEvent::Handle
               fh     => $fh,
               tls    => "connect", # start client-side tls negotiation
               on_eof => sub {
                  undef $handle; # keep it alive till eof
                  warn "done.\n";
                  $cv->send;
               };

            $handle->push_write ("GET / HTTP/1.0\015\012\015\012");

            $handle->push_read_line ("\015\012\015\012", sub {
               my ($handle, $line) = @_;

               # print response header
               print "HEADER\n$line\n\nBODY\n";

               $handle->on_read (sub {
                  # print response body
                  print $_[0]->rbuf;
                  $_[0]->rbuf = "";
               });
            });
         };

      $cv->recv;


-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [EMAIL PROTECTED]
      -=====/_/_//_/\_,_/ /_/\_\

Reply via email to