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

Hi

I have a server and client script working perfectly fine.

Now, I want to create a daemon for my server, so I made an entry in /etc/xinetd.d/sajan as ->

# default: on service sajan { port = 7890 socket_type = stream wait = no user = root server = /tmp/server.pl log_on_success += USERID log_on_failure += USERID disable = no }

Now, when i use the client script to access the server I get error as "Address already in use" at bind() in my server.pl code.

I am doing something wrong somewhere, I need some guidance here.

Thanks for your help in advance.

Replies are listed 'Best First'.
Re: Creating a Server daemon in Socket Programming
by ahmad (Hermit) on Jul 12, 2010 at 14:28 UTC

    I think you should add flags = REUSE to your xinetd.d configuration file

      Hi ahmad

      The flags was what was missing. I am very thankful to you. I was banging my head for last 2 days to resolve this. I had used SO_REUSEADDR flag for bind function. But xinetd require one too.

      Thanks a lot, the issue is resolved.

Re: Creating a Server daemon in Socket Prograaming
by Anonymous Monk on Jul 12, 2010 at 09:22 UTC
    "Address already in use"

    Could it be that the address is already in use?

      Hi

      Forgot to mention that, the port 7890 i am using is not being elsewhere. The port is free.

      I have used it in the daemon and then in the code. I think they are conflicting. I need to fix this, but I don't have the correct idea.

        the port 7890 i am using is not being elsewhere. The port is free.
        Are you sure? It seems your system thinks otherwise. How do you know what the port is free? Have you checked netstat -a |grep 7890?

        Generally useful error messages are... useful. If it says the port is in use, it probably is.
Re: Creating a Server daemon in Socket Programming
by bluescreen (Friar) on Jul 12, 2010 at 14:22 UTC