Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

inetd daemon program

&pagelevel(3)&pagelevel

inetd is one of the Internet daemons in UNIX systems. Since inetd plays a central role when starting the Internet services, it is also called the “Internet superserver”.

As also in UNIX systems, inetd is configured using the /etc/inet/inetd.conf file. inetd is started when the system is booted and uses the inetd.conf file to determine which services are to be started via inetd if required. inetd then creates a socket for each service specified in the inetd.conf file and assigns a port number to each of these sockets.

inetd uses select() for the separate sockets to ensure that they are ready for reading. inetd then monitors the separate sockets with the listen() function for connection requests from the clients.

inetd proceeds as follows with each socket on which a connection request is pending:

  • inetd accepts the connection request with accept().

  • inetd uses fork() and dup() to create two file descriptors for the socket, 0 (stdin) and 1 (stdout).

  • inetd starts the relevant services for the socket with exec().

Using inetd therefore has the advantage that it is not necessary to start all server processes when the system is booted: a server only has to be started when a client has requests for it.

inetd also simplifies the tasks of a server as inetd takes care of most of the communications process during connection setup. The server can assume that the communications endpoint assigned to it has file descriptors 0, 1 and 2 and is already connected to the client. This allows the server to immediately execute functions such as read(), write(), send() or rcv(), i.e. the server program code can be kept very simple.

An application programmer who develops servers started via inetd can get the address of the communications partner, i.e. the address of the client socket, with the getpeername() function.