Loading ...
Sorry, an error occurred while loading the content.

SOAP::Lite problem with HTTP::Daemon

Expand Messages
  • Pierre Denis
    If I use SOAP::Lite as a http standalone forking daemon based on HTTP::Daemon, I have this error message when calling the server: Bad arg length for
    Message 1 of 1 , Aug 1, 2002
    • 0 Attachment
      If I use SOAP::Lite as a http standalone forking daemon based on
      HTTP::Daemon, I have this error message when calling the server:

      Bad arg length for Socket::inet_ntoa, length is 0, should be 4 at
      /usr/local/lib/perl5/site_perl/5.8.0/HTTP/Daemon.pm line 142.


      That can be easily fixed by changing the line 142 of HTTP::Daemon:
      $url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
      into
      $url .= gethostbyaddr($addr, AF_INET) || ($addr ? inet_ntoa($addr) :
      '');


      Is it a SOAP::Lite problem or a HTTP::Daemon problem?

      Environment:
      perl 5.8 and perl 5.6.1
      Linux 2.4.17
      SOAP::Lite and HTTP::Daemon latest




      Server code:


      =head2 start_daemon($server, $port, $path, @dispatch)

      Start a SOAP http daemon dispatching calls to @dispatch modules
      based at $path directory.
      It will listen to port $port.

      =cut
      sub start {
      my ($self, $server, $port, $path, @dispatch) = @_;

      my $daemon = SOAP::Transport::HTTP::Daemon::ForkOnAccept
      -> new (LocalAddr => $server, LocalPort => $port, Reuse
      => 1)
      -> dispatch_to($path, @dispatch);

      print "Contact SOAP server at ".$daemon->url." for any call to
      $path$1@dispatch\n";
      $ENV{server} = $server;
      $daemon->handle;
      }



      ##
      ## SOAP over HTTP forking daemon
      ##

      package SOAP::Transport::HTTP::Daemon::ForkOnAccept;
      use strict;
      use warnings::register;
      use SOAP::Transport::HTTP;

      our @ISA = qw( SOAP::Transport::HTTP::Daemon );

      $SIG{PIPE} = $SIG{CHLD} = 'IGNORE'; # don't want to die on 'Broken pipe' and
      don't want zombies

      sub handle {
      my $self = shift->new;

      CLIENT:
      while (my $c = $self->accept) {
      my $pid = fork();

      # We are going to close the new connection on one of two conditions
      # 1. The fork failed ($pid is undefined)
      # 2. We are the parent ($pid != 0)
      unless( defined $pid && $pid == 0 ) {
      $c->close;
      next;
      }
      # From this point on, we are the child.

      $self->close; # Close the listening socket (always done in children)
      # Handle requests as they come in
      while (my $r = $c->get_request) {
      $self->request($r);
      $self->SOAP::Transport::HTTP::Server::handle;
      $c->send_response($self->response);
      }
      $c->close;
      exit;
      }
      }

      =========================================
      Pierre Denis
      Development Manager
      +44 (0)20 7251 7021
      www.fotango.com


      "Two things are infinite: the universe and stupidity. And the former I'm not
      so sure about." -- Albert Einstein
    Your message has been successfully submitted and would be delivered to recipients shortly.