/[Sack]/trunk/lib/Sack/Client.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Client.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 181 - (show annotations)
Sun Nov 8 12:54:51 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 681 byte(s)
start clients from lib/Sack/

1 #!/usr/bin/perl
2
3 package Sack::Client;
4
5 use warnings;
6 use strict;
7
8 use IO::Socket::INET;
9 use IO::Select;
10 use Storable qw();
11
12 use lib '/srv/Sack/lib';
13 use Data::Dump qw(dump);
14
15 my $port = shift @ARGV;
16
17 my $sock = IO::Socket::INET->new(
18 PeerAddr => '127.0.0.1',
19 PeerPort => $port,
20 Proto => 'tcp',
21 ) || die $!;
22
23 my $sel = IO::Select->new($sock);
24 $sel->add($sock);
25
26 while (1) {
27 for my $sock ($sel->can_read(1)) {
28 my $request = Storable::fd_retrieve($sock);
29 warn "[$port] <<<< ", dump($request), $/;
30 my $response = { port => $port };
31 $response->{ping} = 'pong' if $request->{ping};
32 Storable::store_fd( $response, $sock );
33 warn "[$port] >>>> ", dump($response), $/;
34 }
35 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26