18.4.2 Internet守护进程
提供多项网络服务的Linux系统通常是以超级服务器的方式来运行的,由Internet守护进程inetd同时监听着许多端口地址上的连接。当有客户连接到某项服务时,inetd程序就会运行相应的服务器程序。这使服务器程序不必一直运行着;它们可以在必要时由inetd启动执行。下面是inetd配置文件“/etc/inetd.conf”中的一个片段,这个文件的作用是决定需要运行哪些个服务器。
#
# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
#
# Echo, discard, daytime, and chargen are used primarily for testing.
#
daytime stream tcp nowait root internal
daytime dgram udp wait root internal
#
# These are standard services.
#
ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/wu.ftpd
telnet stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd
#
# End of inetd.conf.
连接daytime服务的操作实际是由inetd本身负责处理的,SOCK_STREAM(tcp)套接字和SOCK_DGRAM(udp)套接字都能使用这项服务。文件传输服务ftp只能通过SOCK_STREAM套接字提供,并且是由一个外部程序提供的。通过编辑该文件并将服务与某一程序相联系,就可以改变通过inetd提供的服务。