/[Sack]/trunk/experiments/protocol-v3/repl.pl
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/experiments/protocol-v3/repl.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 171 - (hide annotations)
Tue Nov 3 17:27:53 2009 UTC (14 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 842 byte(s)
retry connecting to server to give it time to start cloud

1 dpavlin 164 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use Term::ReadLine;
7     use IO::Socket::INET;
8     use Storable qw();
9     use Data::Dump qw(dump);
10    
11 dpavlin 171 my $retries = 0;
12     my $sock;
13 dpavlin 164
14 dpavlin 171 print STDERR "wait for server";
15    
16     while ( $retries < 10 && ! $sock ) {
17     $sock = IO::Socket::INET->new(
18     PeerAddr => '127.0.0.1',
19     PeerPort => 4444,
20     Proto => 'tcp',
21     );
22     if ( ! $sock ) {
23     $retries++;
24     print STDERR ".";
25     sleep 1
26     }
27     }
28    
29     die $! unless $sock;
30    
31     print STDERR "connected after $retries retries\n";
32    
33 dpavlin 164 Storable::fd_retrieve( $sock )->{ping} or die "no ping";
34    
35     my $term = Term::ReadLine->new('Sack');
36     my $prompt = "sack> ";
37     my $OUT = $term->OUT || \*STDOUT;
38     while ( defined ($_ = $term->readline($prompt)) ) {
39     if ( /\S/ ) {
40     warn "# $_\n";
41     Storable::store_fd( { repl => $_ }, $sock );
42     warn "## ", dump( Storable::fd_retrieve( $sock ) );
43     $term->addhistory($_);
44     }
45     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26