/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 163 - (hide annotations)
Sun Nov 1 20:30:48 2009 UTC (14 years, 8 months ago) by dpavlin
Original Path: trunk/experiments/protocol-v3/client.pl
File MIME type: text/plain
File size: 632 byte(s)
new client-server protocol based on IO::Select

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26