my $cv = AnyEvent->condvar;
tcp_connect #'localhost', 8000,
         "
www.google.com", "http",
     sub {
        my ($fh) = @_
           or die "unable to connect: $!";
Â
        my $handle; # avoid direct assignment so on_eof has it in scope.
        $handle = new AnyEvent::Handle
           fh    => $fh,
           _on_error_ => sub {
              AE::log error => $_[2];
              $_[0]->destroy;
           },
           _on_eof_ => sub {
              $handle->destroy; # destroy handle
              AE::log info => "Done.";
           $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;
#Gtk2->main();
########################
This program (taken almost verbatim from the AnyEvent::Socket documentation) works as expected on linux (downloads and prints the Google homepage), and breaks on Windows.