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

Re: [soaplite] ... question about SOAP::Transport::HTTP::Daemon

Expand Messages
  • Duncan Cameron
    ... $self isn t a socket but the class SOAP::Transport::HTTP::Daemon uses Autoload to direct all unknown method calls to HTTP::Daemon, which is a socket. I
    Message 1 of 2 , Dec 31, 2004
    • 0 Attachment
      On 2004-12-31 at 19:36:53 jmzorko wrote:

      >Hello, all ...
      >
      >While i'm looking into POE, I also want to override the handle()
      >method
      >of SOAP::Transport::HTTP::Daemon to use select() (so it's non-
      >blocking)
      >-- just to do it, get better at Perl object stuff, etc. With this
      >in
      >mind, this is what i've tried so far -- perl complains that the
      >add()
      >method won't take what i'm giving it. I'm still fairly new to Perl
      >(perhaps a year or so, on and off) so my question is simply this:
      >How
      >do I tell what an object is i.e. base classes? I think add() is
      >expecting a socket, but $self apparently isn't one (though accept is
      >called on it later).

      $self isn't a socket but the class SOAP::Transport::HTTP::Daemon uses
      Autoload to direct all unknown method calls to HTTP::Daemon, which
      is a socket.

      I think that you need to use $self->{_daemon} as the parameter to the
      add() call.
      >
      >package SOAPDaemon;
      >
      >use strict;
      >use vars qw(@ISA);
      >use IO::Select;
      >use SOAP::Transport::HTTP;
      >
      >@ISA = qw(SOAP::Transport::HTTP::Daemon);
      >
      >sub handle
      >{
      > print "Our own handle() method was called\n\n";
      >
      > my $self = shift->new;
      >
      > my $read_set = new IO::Select();
      > $read_set->add( $self ); ### error here -- $self is not
      >a
      >socket?
      >
      > print "added\n";
      >
      > my $rh_set = IO::Select->select( $read_set, undef, undef, undef );

      This looks wrong. According to the docs, select returns an array not
      a scalar. You may want to use the can_read method instead, if you are
      only interested in reading the socket at this point, see the example
      in the IO::Select docs.

      > if ( @$rh_set[ 0 ] == $self )
      > {
      > my $c = $self->accept;
      >
      > 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@...>
      > # shutdown() doesn't work on AIX. close() is used in this case.
      >Thanks to Jos Clijmans <jos.clijmans@...>
      > UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c->close();
      I know that this has been copied from the
      SOAP::Transport::HTTP::Daemon class but should it be 'can' instead
      of 'isa' ?

      Regards
      Duncan Cameron
    Your message has been successfully submitted and would be delivered to recipients shortly.