HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
Showing results for 
Search instead for 
Did you mean: 

TCPIP KeepAlive

Go to solution
Mark Battle

TCPIP KeepAlive

How do I use the KeepAlive option, from a C program, to prevent a TCPIP connection from disconnecting when there is no traffic for a long time?
There used to be a good site from Digital about TCPIP, but I can't find it anymore.
Honored Contributor

Re: TCPIP KeepAlive

It seems it is in the doc


Appendix A
Socket Options
This appendix describes the socket options that you can set with theSockets APIsetsockopt() function and the $QIO system service IO$_SETMODE and IO$_SETCHAR I/O function codes. You can query the value of these socket options using the Sockets APIgetstockopt() function or the $QIO system service IO$_SENSEMODE or IO$_SENSECHAR I/O function code.

Honored Contributor

Re: TCPIP KeepAlive

In tcpip$examples, you can find some C programs, among them


* 1) To create a socket and set REUSEADDR option:

Not keepidle, but an example on how to set an option on a socket.

For the website, I guess you were looking for

which is now redirected, and I can't find anything with it.

I hope all the good articles
Example-C How to...
Example-Basic and many others
are not lost
Honored Contributor

Re: TCPIP KeepAlive

After you've created your socket, the call should be something like the hollowing:

struct tcp_keepalive {
int idle_time; /* Idle time before first probe */
int probe_intvl; /* Time between probes */
int probe_count; /* Number of probes before closing connection */

Status = setsockopt(socket, IPPROTO_TCP, TCP_KEEPALIVE,
&keepalive, sizeof(keepalive));

Mark Battle

Re: TCPIP KeepAlive

Great. Now it works. Thanks