blob: 468d322bb8e3e84e731b211f56b031af32b105fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/perl -w
use strict;
use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
my $log_socket = '/tmp/log.sock';
my $cv = AnyEvent->condvar;
tcp_connect 'unix/', $log_socket, sub {
my ($fh) = @_ or die "Unable to connect: $!";
my $h; $h = new AnyEvent::Handle
fh => $fh,
on_eof => sub { $h->destroy; $cv->send; },
on_error => sub { die("Connection closed."); };
while (<STDIN>) {
$h->push_write($_);
}
$h->push_shutdown;
$h->destroy;
$cv->send;
};
$cv->recv;
|