Find the answer to your Linux question:
Results 1 to 3 of 3
I'm new to xinetd, and I've been reading through the man pages and the FAQ. Suppose I have a server, foo, that runs on port 5555. I can make one ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    1

    xinetd Behavior


    I'm new to xinetd, and I've been reading through the man pages and the FAQ.

    Suppose I have a server, foo, that runs on port 5555. I can make one connection to it at a time on that port. I want xinetd to fork new instances of foo so multiple clients can connect to it.

    Here's a configuration entry:

    service foo
    {
    type = UNLISTED
    socket_type = stream
    protocol = tcp
    wait = no
    server = /home/user/bin/foo
    port = 5555
    }

    1) How does xinetd fork a new instance of foo when a previous instance is already listening on port 5555? Wouldn't the new process fail to launch because port 5555 is already in use by the previous process?

    2) Suppose five clients connect simultaneously, and xinetd forks five instances of foo. When the clients disconnect, does xinetd leave all five instances running?

    Thanks,

    Peter

  2. #2
    RDU
    RDU is offline
    Just Joined!
    Join Date
    Aug 2010
    Posts
    89
    inetd/xinetd manage all the network socket stuff and all the fork stuf.

    When he receive a cnx, duplicate the socket, fork and start the server given in the config file using standard I/O. So you don't need to bother about socket, fork, cleanup when socket close.... Just do your code using stdin and stdout

    e.g.:
    Install xinetd (urpmi xinetd / yum install xinetd / ....)

    /root/test.sh :
    while (true) do
    read test
    echo $test
    done

    /etc/xinetd.d/test
    service test
    {
    disable = no
    socket_type = stream
    protocol = tcp
    port = 1000
    wait = no
    user = root
    server = /bin/bash
    server_args = /root/test.sh
    }

    /etc/services : add this line
    test 1000/tcp

    # service xinetd restart

    # telnet 127.0.0.1 1000

    should echo each line you type
    (use Ctrl-Alt-] to get the telnet menu and quit)

  3. #3

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •