in reply to Address Bind issue reincarnation

I'm kind of surprised this has ever worked at all (maybe xinetd wasn't running, and you had started the script manually...?).

Normally, when you run a service via (x)inetd, the service is expected to not do bind/listen itself (like a standalone daemon would do). Rather, it simply communicates via stdin/stdout, while the corresponding port/socket is handled by the super-daemon xinetd.

So, as xinetd is already listening on port 7890, your script gets an "Address already in use" when it tries to do the same...

See also inetd and this intro.

Replies are listed 'Best First'.
Re^2: Address Bind issue reincarnation
by sajanagr (Acolyte) on Jul 16, 2010 at 05:43 UTC
    Hi almut,

    Thanks a lot for your reply. I did reconfirm my daemon process and then realized I had used the daemon manually once using " /tmp/server.pl & ".

    Also, by the mean time i read in detail about xinetd and socket programming and came to knw what u mentioned abt communication via stdin/stdout. So, my error is very obvious.

    You had mentioned about inetd. I have started reading about it. But, will it help me make a daemon process for my script. I will be experimenting with that today and let you know.

      You had mentioned about inetd. I have started reading about it. But, will it help me make a daemon process for my script.

      Just to avoid misunderstandings: don't use inetd if you have xinetd.  Essentially, they serve the same purpose, but xinetd is the more modern, more secure incarnation. — I just linked to inetd, because the respective wikipedia page for xinetd didn't have the crucial bit of info about stdin/stdout...

      P.S.: in case you want to run your script persistently as a regular standalone daemon (not managed by xinetd, thus doing networking itself), you might be interested in daemontools.  In this case, you'd have to add an accept loop to your script, though.

        Hi almut,

        I wished to use xinetd first, but since my server code i wrote is using socket functions, so the communication is not through stdin/stdout which brings me to the 'Address bind' issue

        I am trying another approach of making a standalone daemon. The goal is to make a server daemon listening to a port continuously.

        I read the links you sent me, thanks a lot. I am thinking now to make a script in /etc/init.d/ and define a run level for it. What do you say?