/[Sack]/trunk/lib/Sack/Server.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

Diff of /trunk/lib/Sack/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 209 by dpavlin, Sat Nov 21 13:59:41 2009 UTC revision 210 by dpavlin, Sat Nov 21 15:55:24 2009 UTC
# Line 15  use Cwd qw(abs_path); Line 15  use Cwd qw(abs_path);
15    
16  use lib '/srv/Sack/lib';  use lib '/srv/Sack/lib';
17  use Sack::Merge;  use Sack::Merge;
18    use Sack::Server::HTTP;
19    
20  my @cloud;  my @cloud;
21  my $cloud_path = $ENV{CLOUD} || "etc/cloud";  my $cloud_path = $ENV{CLOUD} || "etc/cloud";
# Line 25  die "start with: CLOUD=etc/cloud perl -I Line 26  die "start with: CLOUD=etc/cloud perl -I
26  warn "# cloud ",dump( @cloud );  warn "# cloud ",dump( @cloud );
27    
28  my $listen_port = 4444;  my $listen_port = 4444;
29    my $http_port   = 4480;
30    
31  my $node_path = abs_path $0;  my $node_path = abs_path $0;
32  $node_path =~ s{Server}{Client};  $node_path =~ s{Server}{Client};
33    
34  my $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => $listen_port, Reuse => 1) or die $!;  my $lsn = IO::Socket::INET->new(Listen => 1, LocalPort => $listen_port, Reuse => 1) or die "$listen_port $!";
35    my $www = IO::Socket::INET->new(Listen => 1, LocalPort => $http_port,   Reuse => 1) or die "$http_port $!";
36  my $sel = IO::Select->new($lsn);  my $sel = IO::Select->new($lsn);
37    $sel->add( $www );
38    
39  my $info;  my $info;
40  sub info {  sub info {
# Line 85  while (1) { Line 89  while (1) {
89                          warn "[socket] connect\n";                          warn "[socket] connect\n";
90                          Storable::store_fd( { ping => 1 }, $new );                          Storable::store_fd( { ping => 1 }, $new );
91                          info 0 => 'ping', $new->peerport;                          info 0 => 'ping', $new->peerport;
92                    } elsif ( $sock == $www ) {
93                            my $client = $www->accept;
94                            Sack::Server::HTTP::request( $client, sub {
95    warn "XXX callback ",dump( @_ );
96                                    my ( $send, $method, $param ) = @_;
97                                    print $send "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n"
98                                            , dump( $info )
99                                            ;
100                            } );
101                  } else {                  } else {
102                          my $data = eval { Storable::fd_retrieve( $sock ) };                          my $data = eval { Storable::fd_retrieve( $sock ) };
103                          if ( $@ ) {                          if ( $@ ) {

Legend:
Removed from v.209  
changed lines
  Added in v.210

  ViewVC Help
Powered by ViewVC 1.1.26