Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've just been looking through network programming with perl and at one point it talks about using inetd to start up a server on a machine when it gets a connection on a specific port. However the computers I have access to use xinetd, and I'm suspecting it deals with things differently. the client program always hangs whenever it has to read or write to the server (which works fine at the command line). The server has been started (shows up in ps ) and I've managed to get some stuff through (generally comes when i've sent the command to quit. but nothing before that) So I was wondering, has anyone used this? I don't want the server program running constantly, just when needed.

Replies are listed 'Best First'.
Re: xinetd and perl
by fuzzysteve (Beadle) on Nov 26, 2001 at 18:34 UTC
    Found the answer. the problem was the stdio caching. set it to auto flush, and it works fine. Took me long enough to find it.
      in case anyone was wondering, to use xinetd to act as a super server for your code, you need to add the following kind of thing to a new file (call it what you want to. I'd suggest something descriptive) in /etc/xinetd.d/
      service servermon { disable = no socket_type = stream wait = no user = root instances = 3 server = /home/backup/servermon/monitord.pl log_on_failure += USERID }
      and the following kind of line at the bottom of /etc/services
      servermon 2345/tcp
      (the name of the service has to match the name in ect services, or you have to give more details.man xinetd.conf is fairly explanetory)
      then your program just has to read and write to stdin and stdout. (stderr is also redirected.) The bit that caught me was, you need to make sure that stdio is flushing its cache. $|=1; will do this for you.
Re: xinetd and perl
by fuzzysteve (Beadle) on Nov 26, 2001 at 16:59 UTC
    oops, forgot to log in. This one's mine.