HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using TCP_KEEPALIVE option in setsockopt to detect...
Operating System - HP-UX
1827814
Members
2434
Online
109969
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2004 01:31 AM
10-15-2004 01:31 AM
Using TCP_KEEPALIVE option in setsockopt to detect cable break
I would like to enable tcp keepalive packets for a particular socket in a C server application hosted on HPUX 11.00. I'm trying to use the TCP_KEEPALIVE option:
int fd, ret, len, optval=1;
fd = socket(AF_INET, SOCK_STREAM, 0);
len = sizeof(optval);
// It's necessary set SO_KEEPALIVE to use TCP_KEEPALIVE
ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, optval, &len);
struct t_kpalive kp_opts;
len = sizeof(struct t_kpalive);
kp_opts.kp_onoff = 1;
kp_opts.kp_timeout = 200;
ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &kp_opts, len);
struct t_kpalive kp_optget;
len = sizeof(struct t_kpalive);
ret = getsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &kp_optget, &len);
printf("onoff=%d, timeout=%d \n", kp_optget.kp_onoff, kp_optget.kp_timeout);
The result of the printf is:
"onoff=0, timeout=0"
This means that I didn't change de timeout, right? Has anyone any ideas how to resolve the problem?
Thanks
int fd, ret, len, optval=1;
fd = socket(AF_INET, SOCK_STREAM, 0);
len = sizeof(optval);
// It's necessary set SO_KEEPALIVE to use TCP_KEEPALIVE
ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, optval, &len);
struct t_kpalive kp_opts;
len = sizeof(struct t_kpalive);
kp_opts.kp_onoff = 1;
kp_opts.kp_timeout = 200;
ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &kp_opts, len);
struct t_kpalive kp_optget;
len = sizeof(struct t_kpalive);
ret = getsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &kp_optget, &len);
printf("onoff=%d, timeout=%d \n", kp_optget.kp_onoff, kp_optget.kp_timeout);
The result of the printf is:
"onoff=0, timeout=0"
This means that I didn't change de timeout, right? Has anyone any ideas how to resolve the problem?
Thanks
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 08:01 AM
10-24-2004 08:01 AM
Re: Using TCP_KEEPALIVE option in setsockopt to detect cable break
If the abort interval is set to a small value and the RTT estimate is a large value, then that will lead to fewer retransmissions before the connection is aborted. The application writer must understand the ramifications before they attempt to modify the values of these options. The values of these options can also be retrieved using getsockopt.
The total elapsed time is a function of the following parameters:
tcp_keepalive_interval
tcp_ip_abort_interval
Estimated round trip time
The number of retransmissions before the connection is aborted is a
function of the following parameters:
tcp_ip_abort_interval
estimated round trip time
I'm Not sure if it's possible for an application to precisely estimate or control
the total time before a connection is aborted or the number of retransmissions which are sent before the connection is aborted. These things are dependent on factors (tcp->tcp_rto) over which the application does not and should not have control.
Applications may use an application-level keepalive mechanism.This mechanism will allow the application to have precise control over the amount of time it will wait before giving up on a connection.
Hope this Helps..
Cheers
Asif
The total elapsed time is a function of the following parameters:
tcp_keepalive_interval
tcp_ip_abort_interval
Estimated round trip time
The number of retransmissions before the connection is aborted is a
function of the following parameters:
tcp_ip_abort_interval
estimated round trip time
I'm Not sure if it's possible for an application to precisely estimate or control
the total time before a connection is aborted or the number of retransmissions which are sent before the connection is aborted. These things are dependent on factors (tcp->tcp_rto) over which the application does not and should not have control.
Applications may use an application-level keepalive mechanism.This mechanism will allow the application to have precise control over the amount of time it will wait before giving up on a connection.
Hope this Helps..
Cheers
Asif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 07:44 PM
10-24-2004 07:44 PM
Re: Using TCP_KEEPALIVE option in setsockopt to detect cable break
Hi
look at
man ndd
and
http://www.sybase.com/detail?id=611
Steve Steel
look at
man ndd
and
http://www.sybase.com/detail?id=611
Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP