- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using SO_KEEPALIVE option in setsockopt to detect ...
Operating System - HP-UX
1821642
Members
2819
Online
109633
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
Discussions
Discussions
Discussions
Forums
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
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
тАО02-13-2002 02:19 AM
тАО02-13-2002 02:19 AM
Using SO_KEEPALIVE option in setsockopt to detect cable break
I have a java 1.2 client application on a PC which is communicating to a C++ server application hosted on HPUX 10.20 or HPUX 11.00
If I disconnect the PC by pulling the ethernet cable while the java client is connected to the server - then kill the java client - then reconnect the ethernet cable.
The server remains connected and netstat reports TCP Connection established.
I thought to resolve the problem using the TCP keepalive timer at the application level.
int keep;
m_fd = ::socket(AF_INET,SOCK_STREAM,0);
int len = sizeof(int);
getsockopt(m_fd,SOL_SOCKET,SO_KEEPALIVE,&keep,&len);
//keep is set to 0
keep= 30000; // 5mins I think
setsockopt(m_fd,SOL_SOCKET,SO_KEEPALIVE,&keep,len);
if (!::setsockopt(m_fd,SOL_SOCKET,SO_REUSEADDR,&enable,sizeof(int)) &&
!bind(m_fd, reinterpret_cast(&localAddress), sizeo
f(sockaddr_in)) &&
!::listen(m_fd,SOMAXCONN) && (::fcntl(m_fd,F_SETFL,::fcntl(m_fd,F_GETFL,0) | O_NONBLOCK) != -1))
{
.....
This code does not seem to do anything.
Has anyone any ideas how to resolve the problem?
If I disconnect the PC by pulling the ethernet cable while the java client is connected to the server - then kill the java client - then reconnect the ethernet cable.
The server remains connected and netstat reports TCP Connection established.
I thought to resolve the problem using the TCP keepalive timer at the application level.
int keep;
m_fd = ::socket(AF_INET,SOCK_STREAM,0);
int len = sizeof(int);
getsockopt(m_fd,SOL_SOCKET,SO_KEEPALIVE,&keep,&len);
//keep is set to 0
keep= 30000; // 5mins I think
setsockopt(m_fd,SOL_SOCKET,SO_KEEPALIVE,&keep,len);
if (!::setsockopt(m_fd,SOL_SOCKET,SO_REUSEADDR,&enable,sizeof(int)) &&
!bind(m_fd, reinterpret_cast
f(sockaddr_in)) &&
!::listen(m_fd,SOMAXCONN) && (::fcntl(m_fd,F_SETFL,::fcntl(m_fd,F_GETFL,0) | O_NONBLOCK) != -1))
{
.....
This code does not seem to do anything.
Has anyone any ideas how to resolve the problem?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2003 05:47 AM
тАО09-15-2003 05:47 AM
Re: Using SO_KEEPALIVE option in setsockopt to detect cable break
Hi,
I hope you would have implemented KEEPALIVE in c++code ie server application. I would also suggest to check the return value of setsockopt.
from
Vijay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2003 06:07 AM
тАО09-15-2003 06:07 AM
Re: Using SO_KEEPALIVE option in setsockopt to detect cable break
Hi,
Agree with Vijay, you need KEEPALIVE on both sides. It looks like you don??t have the appropiate code in the C++ program, or maybe you need to wait more time ( KEEPALIVE time interval )?
If your PC is running Windows also need to add some keys to registry.
Hope this helps.
Kind regards,
Zigor
Agree with Vijay, you need KEEPALIVE on both sides. It looks like you don??t have the appropiate code in the C++ program, or maybe you need to wait more time ( KEEPALIVE time interval )?
If your PC is running Windows also need to add some keys to registry.
Hope this helps.
Kind regards,
Zigor
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
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP