1752290 Members
5004 Online
108786 Solutions
New Discussion юеВ

Re: TCPIP KeepAlive

 
SOLVED
Go to solution
Mark Battle
Advisor

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.
4 REPLIES 4
labadie_1
Honored Contributor
Solution

Re: TCPIP KeepAlive

It seems it is in the doc

http://h71000.www7.hp.com/doc/73final/6529/6529pro_022.html

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.

labadie_1
Honored Contributor

Re: TCPIP KeepAlive

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

SYS$COMMON:[SYSHLP.EXAMPLES.TCPIP]TCPIP$TCP_SERVER_QIO.C;1

shows
* 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
http://askq.compaq.com

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

I hope all the good articles
Example-C How to...
and
Example-Basic and many others
are not lost
Jim_McKinney
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
Advisor

Re: TCPIP KeepAlive

Great. Now it works. Thanks