HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 66
So_keepalive
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 66 highlights
Advanced Topics for Stream Sockets Socket Options Network Daemon Server Listening at Port 2000. When the network daemon accepts a connection request, the accepted socket will bind to port 2000 and to the address where the daemon is running (e.g. 192.6.250.100). If you executed netstat an, the output would resemble: Active connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 192.6.250.100.2000 192.6.250.101.4000 ESTABLISHED tcp 0 0 *.2000 *.* LISTEN New Connection Established, Daemon Server Still Listening. Here the network daemon has established a connection to the client (192.6.250.101.4000) with a new server socket. The original network daemon server continues to listen for more connection requests. If the listening network daemon process is killed, attempts to restart the daemon fail if SO_REUSEADDR is not set. The restart fails because the daemon attempts to bind to port 2000 and a wildcard IP address (e.g. *.2000). The wildcard address matches the address of the established connection (192.6.250.100), so the bind aborts to avoid duplicate socket naming. When SO_REUSEADDR is set, bind ignores the wildcard match, so the network daemon can be restarted. An example usage of this option is: int optval = 1; setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); bind (s, &sin, sizeof(sin)); SO_KEEPALIVE This option is AF_INET socket-specific. This option enables the periodic transmission of messages on a connected socket. This occurs at the transport level and does not require any work in your application programs. If the peer socket does not respond to these messages, the connection is considered broken. The next time one of your processes attempts to use a connection that is considered broken, the process is notified (with a SIGPIPE signal if you are trying to send, or an end-of-file condition if you are trying to receive) that the connection is broken. 66 Chapter 3