Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

SOAP::Lite Servers and inetd

by tektsu (Acolyte)
on Apr 15, 2004 at 21:52 UTC ( #345567=perlquestion: print w/replies, xml ) Need Help??
tektsu has asked for the wisdom of the Perl Monks concerning the following question:

I have found no end of useful documentation on writing SOAP Servers. Unfortunately, I haven't been ubale to figure out what I want to do, so I'm hoping someone here will have this elusive information.

I want to write a standalone forking server, which will allow me to add or modify methods without stopping and restarting the server. That would be easy if I was using SOAP CGI scripts through a webserver, but I will not have webservers on these boxes.

I'm wondering if it would be possible to run the server through inetd. So far, I have not had any success in doing so, but I'm certainly willing to entertain the propect that I am clueless as an explanation for that. Anyone have any pointers? Or alternative ways of doing this?

Thanks



tektsu
kiku wa ittoki no haji kikanu wa matsudai no haji

Replies are listed 'Best First'.
Re: SOAP::Lite Servers and inetd
by rob_au (Abbot) on Apr 16, 2004 at 02:53 UTC
    By default SOAP::Transport::IO uses STDIN and STDOUT for input and output and as such it should be quite trivial to implement an inetd based SOAP server - The following is an untested inetd-based SOAP server based upon some existing code which I had on hand.
    #!/opt/bin/perl package main; # For Perl 6 forward-compatability # The following constants are used to define server timeout and sock +et # timeout behaviour. sub TIMEOUT_PEER () { 60 } sub TIMEOUT_SERVER () { 300 } use IO::Socket; use POSIX qw( WNOHANG ); use SOAP::Transport::IO; use Socket qw( :crlf ); use vars qw( $VERSION ); $VERSION = sprintf( "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/ ); # Define signal handlers for timeout and child events $SIG{'ALRM'} = sub { exit 0 }; $SIG{'CHLD'} = sub { while ( waitpid( -1, WNOHANG ) > 0) {} }; # Create IO socket from STDIN file descriptor on which the network # communication socket is duplicated for the server process by the i +netd # daemon. my $socket = IO::Socket->new_from_fd( STDIN, 'r+' ); unless ( defined $socket ) { croak( 'Cannot create socket from STDIN -- ', $! ); } while ( my $connection = $socket->accept ) { my $child = undef; unless ( defined ( $child = fork() ) ) { croak( 'Cannot fork process to handle new connection -- ', $! +); } if ( $child == 0 ) { # Clear the alarm timeout, close the parent socket and initi +ate # communication with POP3 client. alarm(0); $socket->close; STDIN->fdopen( $connection, 'r' ) or croak( 'Cannot re-open STDIN for input -- ', $! ); STDOUT->fdopen( $connection, 'w' ) or croak( 'Cannot re-open STDOUT for output -- ', $! ); STDERR->fdopen( $connection, 'w' ) or croak( 'Cannot re-open STDERR for output -- ', $! ); STDOUT->autoflush(1); SOAP::Transport::IO::Server ->new ->dispatch_to('/path/to/modules', 'Local::Module') ->handle; } } continue { $connection->close; alarm( TIMEOUT_SERVER ); exit 0; } 1; __END__

     

    perl -le "print unpack'N', pack'B32', '00000000000000000000001011010001'"

      Excellent! This is just what I was looking for (I guess I should have looked a little harder...).

      Thanks!



      tektsu
      kiku wa ittoki no haji kikanu wa matsudai no haji

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://345567]
Approved by kvale
help
Chatterbox?
[Eily]: Astérix
1nickt gives up on finding a Perl YAML parser that supports hash merging. In 2017.
[LanX]: Oh yes true, he lost his accent! xD
[Eily]: and since his name is a modified version of astérisque (asterisk), which is a typographical symbol, I think it's even funnier that he would lose a diacritic
[Eily]: the pun doesn't work so well with "he lost a diacritic" though :P
[LanX]: Obelix might offer to find it again ...
[LanX]: not much to translate anyway since Goscinny died
[Eily]: https://en. wikipedia.org/ wiki/List_of_Aster ix_characters some of the names were changed to include a new pun
[LanX]: sure some are even funnier now
[LanX]: some lost because they were not translated like Epidemais

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2017-05-24 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?