[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/linuxaux/opt/perl/lib/site_perl/5.10.0/i586-linux-thread-multi/DBI/Gofer/Transport/ -> stream.pm (source)

   1  package DBI::Gofer::Transport::stream;
   2  
   3  #   $Id: stream.pm 10087 2007-10-16 12:42:37Z timbo $
   4  #
   5  #   Copyright (c) 2007, Tim Bunce, Ireland
   6  #
   7  #   You may distribute under the terms of either the GNU General Public
   8  #   License or the Artistic License, as specified in the Perl README file.
   9  
  10  use strict;
  11  use warnings;
  12  
  13  use DBI qw(dbi_time);
  14  use DBI::Gofer::Execute;
  15  
  16  use base qw(DBI::Gofer::Transport::pipeone Exporter);
  17  
  18  our $VERSION = sprintf("0.%06d", q$Revision: 10087 $ =~ /(\d+)/o);
  19  
  20  our @EXPORT = qw(run_stdio_hex);
  21  
  22  my $executor = DBI::Gofer::Execute->new();
  23  
  24  sub run_stdio_hex {
  25  
  26      my $transport = DBI::Gofer::Transport::stream->new();
  27      local $| = 1;
  28  
  29      DBI->trace_msg("$0 started (pid $$)\n");
  30  
  31      local $\; # OUTPUT_RECORD_SEPARATOR
  32      local $/ = "\012"; # INPUT_RECORD_SEPARATOR
  33      while ( defined( my $encoded_request = <STDIN> ) ) {
  34          my $time_received = dbi_time();
  35          $encoded_request =~ s/\015?\012$//;
  36  
  37          my $frozen_request = pack "H*", $encoded_request;
  38          my $request = $transport->thaw_request( $frozen_request );
  39  
  40          my $response = $executor->execute_request( $request );
  41  
  42          my $frozen_response = $transport->freeze_response($response);
  43          my $encoded_response = unpack "H*", $frozen_response;
  44  
  45          print $encoded_response, "\015\012"; # autoflushed due to $|=1
  46  
  47          # there's no way to access the stats currently
  48          # so this just serves as a basic test and illustration of update_stats()
  49          $executor->update_stats($request, $response, $frozen_request, $frozen_response, $time_received);
  50      }
  51      DBI->trace_msg("$0 ending (pid $$)\n");
  52  }
  53  
  54  1;
  55  __END__
  56  
  57  =head1 NAME
  58  
  59  DBI::Gofer::Transport::stream - DBD::Gofer server-side transport for stream
  60  
  61  =head1 SYNOPSIS
  62  
  63  See L<DBD::Gofer::Transport::stream>.
  64  
  65  =head1 AUTHOR
  66  
  67  Tim Bunce, L<http://www.tim.bunce.name>
  68  
  69  =head1 LICENCE AND COPYRIGHT
  70  
  71  Copyright (c) 2007, Tim Bunce, Ireland. All rights reserved.
  72  
  73  This module is free software; you can redistribute it and/or
  74  modify it under the same terms as Perl itself. See L<perlartistic>.
  75  
  76  =cut


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1