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

accessing client II address for logfile

Expand Messages
  • adavisirl
    I d like to have my SOAP server write the IP address of clients to a logfile. I ve been trying to use SOAP::Trace to grab the address, but I guess the headers
    Message 1 of 2 , Jun 3, 2005
    • 0 Attachment
      I'd like to have my SOAP server write the
      IP address of clients to a logfile. I've been
      trying to use SOAP::Trace to grab the address, but
      I guess the headers signal is not yet implemented.

      Can someone give me an idea how to access the
      headers of incoming messages? Here's my real
      simple server, to let you know what a newbie I am!

      use Discover;
      use GetDetails;
      use GetData;
      use Data::Dumper;

      sub log_message {
      my ($stuff) = @_;
      printf STDERR Dumper($stuff);
      }

      use SOAP::Lite +trace => [ all => \&log_message];

      use SOAP::Transport::HTTP;

      BEGIN{ open( STDERR, '>>Server.log') ;
      my $date=`date`;
      chomp $date;
      printf STDERR "===$date ACE_SOAP_server started===\n";
      }

      SOAP::Transport::HTTP::CGI
      ->dispatch_to('Discover','GetDetails','GetData')
      ->handle;

      Thanks,
      Andrew
    • Artur Brodowski
      ... Try this: use SOAP::Transport::HTTP; sub SOAP::Transport::HTTP::Daemon::handle { my $self = shift- new; while (my ($c, $peer_addr) = $self- accept) { my
      Message 2 of 2 , Jun 13, 2005
      • 0 Attachment
        Dnia 04-06-2005, sob o godzinie 03:03 +0000, adavisirl napisaƂ(a):
        > I'd like to have my SOAP server write the
        > IP address of clients to a logfile. I've been
        > trying to use SOAP::Trace to grab the address, but
        > I guess the headers signal is not yet implemented.

        Try this:

        use SOAP::Transport::HTTP;

        sub SOAP::Transport::HTTP::Daemon::handle {
        my $self = shift->new;

        while (my ($c, $peer_addr) = $self->accept) {
        my ($port, $iaddr) = sockaddr_in($peer_addr);
        $client_ip = inet_ntoa($iaddr);
        _log("Connection from " . $client_ip . ":" . $port . "\n");
        while (my $r = $c->get_request) {
        $self->request($r);
        $self->SOAP::Transport::HTTP::Server::handle;
        $c->send_response($self->response)
        }
        UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c->close();
        undef $c;
        }
        }

        my $daemon = SOAP::Transport::HTTP::Daemon->new(
        # .... args

        $daemon->handle;

        AB.
        --
        only so many songs can be sung with two lips two lungs and one tongue
      Your message has been successfully submitted and would be delivered to recipients shortly.