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

[PATCH] RE: [soaplite] Subclassing SOAP::Transport::HTTP::Daemon

Expand Messages
  • Michael Percy
    Sorry for the spam, the list formatted my previous post horribly. Here goes one more time... Paul, I got rid of my SIG{INT} handler because it was messy :-),
    Message 1 of 1 , Feb 14, 2001
    View Source
    • 0 Attachment
      Sorry for the spam, the list formatted my previous post horribly. Here goes
      one more time...

      Paul,
      I got rid of my SIG{INT} handler because it was messy :-), but I don't think
      it is needed. The IO::Socket::INET class specifies a parameter called
      "Reuse", which allows for the reuse of a still-open (?) socket. I don't
      totally understand it however it seems like the best way to do thinks if you
      want your port to always be available after a Ctrl-C.

      Also, I have added a SIG{PIPE} handler which seems to work great where it is
      in the code. I hope you find this useful. Code follows:

      --
      #!/usr/local/bin/perl -w
      #########################################################################
      package main;
      use strict;

      my $PORT = 12039;
      my $daemon = My::Daemon
      -> new (LocalPort => $PORT,
      Reuse => 1) # <-----
      -> dispatch_to('TestClass');

      print "Access me at: ", $daemon->url(), "\n";
      $daemon->handle();

      # ====================================================

      BEGIN {
      package My::Daemon;
      use strict;

      use SOAP::Transport::HTTP;
      use vars qw(@ISA);
      @ISA = ('SOAP::Transport::HTTP::Daemon');

      sub handle {
      my $self = shift->new;
      CONN: while (my $c = $self->accept) {
      local $SIG{PIPE} = sub { # <-----
      warn "SIGPIPE: $!"; # <-----
      $c->close; # <-----
      return 0; # <-----
      }; # <-----
      while (my $r = $c->get_request) {
      $self->request($r);
      $self->SOAP::Transport::HTTP::Server::handle;
      $c->send_response($self->response);
      }
      $c->close;
      undef $c;
      }
      }
      }
      --

      Regards,
      Michael Percy

      > -----Original Message-----
      > From: Paul Kulchenko [mailto:paulclinger@...]
      > Sent: Tuesday, February 13, 2001 2:05 PM
      > To: soaplite@yahoogroups.com
      > Subject: Re: [soaplite] Subclassing SOAP::Transport::HTTP::Daemon
      >
      >
      > Hi, Michael!
      >
      > Why not? There is no restrictions on subclassing or inheritance. Take
      > a look into examples/SOAP/Transport/HTTP/ForkingDaemon which is
      > inherited from SOAP::Transport::HTTP::Daemon.
      >
      > As for SIG{INT} I planned to add SIG{PIPE} and SIG{INT} handlers, but
      > don't do it yet, so if you could provide a code or example I'll
      > incorporate it into Transport::HTTP::Daemon implementation. Thank
      > you.
      >
      > Best wishes, Paul.
      >
      > --- Michael Percy <mpercy@...> wrote:
      > > Hello,
      > > I am trying to catch SIG{INT} and gracefully close the connection
      > > in the
      > > daemon implementation of the SOAP::Lite server. However, I cannot
      > > seem to
      > > subclass SOAP::Transport::HTTP::Daemon!
      > >
      > > I believe this problem stems from the fact that all of the
      > > SOAP::Transport::HTTP::* classes reside in one file:
      > > SOAP/Transport/HTTP.pm.
      > > I am perfectly able to "use SOAP::Transport::HTTP" and then
      > > instantiate a
      > > ::Daemon class or ::Server class but I cannot for the life of me
      > > inherit
      > > from one!
      > >
      > > When I put SOAP::Transport::HTTP::Daemon in my @ISA array, even if
      > > I am
      > > "use"ing SOAP::Transport::HTTP, when I try to create an object of
      > > my
      > > subclass I get the error: 'Can't locate object method "new" via
      > > package
      > > "MyDaemon"' (my subclass). It is really strange.
      > >
      > > Does the @ISA "classloader" mechanism work differently that the
      > > @INC
      > > classloader mechanism? What I mean is, am I doing something
      > > wrong/being
      > > stupid, is Perl having problems, or was what the author did an
      > > unsupported
      > > use of packages/classes?
      > >
      > > Is there a workaround? ( !!! :-)
      > >
      > > Hope I have been clear enough!
      > >
      > >
      > > Regards,
      > >
      > > Michael Percy
      > > Software Engineer, Portera Systems
      > >
      > > ------------------------ Yahoo! Groups Sponsor
      > >
      > > To unsubscribe from this group, send an email to:
      > > soaplite-unsubscribe@yahoogroups.com
      > >
      > >
      > >
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Get personalized email addresses from Yahoo! Mail - only $35
      > a year! http://personal.mail.yahoo.com/
      >
      > ------------------------ Yahoo! Groups Sponsor
      > ---------------------~-~>
      > eGroups is now Yahoo! Groups
      > Click here for more details
      > http://click.egroups.com/1/11231/1/_/_/_/982101923/
      > --------------------------------------------------------------
      > -------_->
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.