HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 169
Adding a Server Process to the Internet, Daemon
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 169 highlights
Programming Hints Adding a Server Process to the Internet Daemon Adding a Server Process to the Internet Daemon This section contains example BSD Sockets programs that use the internet daemon, called inetd. For more information on inetd, refer to the inetd(1M) man page. You can invoke the example server programs from inetd if you have super-user capabilities and you make the following configuration modifications: • Add the following lines to the /etc/inetd.conf file: example stream tcp nowait root /server.tcp server.tcp example dgram udp wait root /server.udp server.udp where is the path to the files on your host. • Add the following lines to the /etc/services file: example 22375/tcp example 22375/udp • If inetd is already running, execute the following command so that inetd recognizes the changes: /etc/inetd -c These example programs do the same thing as the previous example servers do, but they are designed to be called from inetd. They do not have daemon loops or listen for incoming connection requests, because inetd does that. The source code for the two example servers follows. /* * S E R V E R . T C P * * This is a variation of the example program called serv.tcp. * This one performs the same function, except that it is * designed to be called from /etc/inetd. This version does * not contain a daemon loop, and does not listen for incoming * connections on the socket. /etc/inetd does these functions. * This server simply assumes that the socket to receive the * messages from and send the responses to is file descriptor * 0 when the program is started. It also assumes that * the client connection is already established to the socket. * For the sake of simplicity, the activity logging * functions of serv.tcp have also been removed. * */ /* Chapter 8 169