Now I have access to the client's IP and port as can be seen in warn "$af connection from ".join ('.', @inetaddr).":$client_port\n";package Message::Daemon; use SOAP::Transport::HTTP; use Socket; use Carp (); use vars qw($AUTOLOAD @ISA); @ISA = qw(SOAP::Transport::HTTP::Server); sub DESTROY { SOAP::Trace::objects('()') } sub new { require HTTP::Daemon; my $self = shift; unless (ref $self) { my $class = ref($self) || $self; my(@params, @methods); while (@_) { $class->can($_[0]) ? push(@methods, shift() => shift) + : push(@params, shift) } $self = $class->SUPER::new; $self->{_daemon} = HTTP::Daemon->new(@params) or Carp::croak "Can' +t create daemon: $!"; $self->myuri(URI->new($self->url)->canonical->as_string); while (@methods) { my($method, $params) = splice(@methods,0,2); $self->$method(ref $params eq 'ARRAY' ? @$params : $params) } SOAP::Trace::objects('()'); } return $self; } sub AUTOLOAD { my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2); return if $method eq 'DESTROY'; no strict 'refs'; *$AUTOLOAD = sub { shift->{_daemon}->$method(@_) }; goto &$AUTOLOAD; } sub handle { my $self = shift->new; while (my ($c, $peer) = $self->accept) { my $sockaddr_template = 'Sna4x8'; my ($af,$client_port,$client_ip) = unpack($sockaddr_template,$peer +); my @inetaddr = unpack('C4',$client_ip); warn "$af connection from ".join ('.', @inetaddr).":$client_port\n +"; while (my $r = $c->get_request) { $self->request($r); $self->SUPER::handle; $c->send_response($self->response) } # replaced ->close, thanks to Sean Meisner <Sean.Meisner@VerizonWi +reless.com> # shutdown() doesn't work on AIX. close() is used in this case. Th +anks to Jos Clijmans <jos.clijmans@recyfin.be> UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c->close(); undef $c; } }
In reply to Re: SOAP client IP
by m-rau
in thread SOAP client IP
by m-rau
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |