- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to detect connect() drops due to unavailable s...
Operating System - HP-UX
1754412
Members
3222
Online
108813
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
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
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
04-22-2009 05:48 AM
04-22-2009 05:48 AM
How to detect connect() drops due to unavailable server
Hi,
I followed the following steps to test handling of connect failure in HP UX.
I first stopped the service :
kill -s SIGSTOP
My program connected to the service using the code :
socket(AF_UNIX,SOCK_STREAM,0)
int sp = connect(sp,(sockaddr*)&server_address, server_len);
i was expecting connect to fail because the service which it is connecting to has stopped. But connect still returned non negative value.
Also when i checked netstat -s, it said socket connects dropped due to server unavialble.
How do i detect such drops?
Also, after the connect was succesful, my program tried to recv() data from the socket descriptor and got blocked there.
Please help me in this regard.
Thanks and Regards,
Ashwini
I followed the following steps to test handling of connect failure in HP UX.
I first stopped the service :
kill -s SIGSTOP
My program connected to the service using the code :
socket(AF_UNIX,SOCK_STREAM,0)
int sp = connect(sp,(sockaddr*)&server_address, server_len);
i was expecting connect to fail because the service which it is connecting to has stopped. But connect still returned non negative value.
Also when i checked netstat -s, it said socket connects dropped due to server unavialble.
How do i detect such drops?
Also, after the connect was succesful, my program tried to recv() data from the socket descriptor and got blocked there.
Please help me in this regard.
Thanks and Regards,
Ashwini
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 11:55 AM
04-22-2009 11:55 AM
Re: How to detect connect() drops due to unavailable server
SIGSTOP is a bit of a misnomer. It does not exactly "stop" a process... "pause" would be a better word. SIGCONT would allow the process to continue exactly from the point it was stopped. This is why the OS will keep the network sockets alive. Any incoming connections will wait in the queue of the listening socket.
Of course, if the process is paused for a long time and enough incoming data from network connections remains unacknowledged, those connections will time out. If the process is unpaused after that, it may be in a situation from which it is difficult to continue.
SIGSTOP is like SIGKILL: the process cannot catch, block nor ignore it. When someone sends SIGSTOP to a process, the OS simply stops giving any CPU time for that process.
One way to detect such a situation would be to connect to first set up a timer (see "man 2 alarm" or "man 2 setitimer") with a suitable time-out value, then send a message to the server.
If the server does not respond correctly before the timer is triggered, you'll know that the service is either:
- seriously overloaded (the server does not have enough free CPU time to service you)
- paused with SIGSTOP, or
- stuck in some way (in an infinite loop, or waiting for something else that is unresponsive)
Any of these is a good reason to report the service as unresponsive. For more information, you will usually need to examine the service's logs or use other diagnostic tools to find out the state of the service.
If your program is written to specifically monitor the service, you might want to set the socket in non-blocking mode before using it to connect to the service. That allows you to catch more errors immediately, without waiting for a time-out.
MK
Of course, if the process is paused for a long time and enough incoming data from network connections remains unacknowledged, those connections will time out. If the process is unpaused after that, it may be in a situation from which it is difficult to continue.
SIGSTOP is like SIGKILL: the process cannot catch, block nor ignore it. When someone sends SIGSTOP to a process, the OS simply stops giving any CPU time for that process.
One way to detect such a situation would be to connect to first set up a timer (see "man 2 alarm" or "man 2 setitimer") with a suitable time-out value, then send a message to the server.
If the server does not respond correctly before the timer is triggered, you'll know that the service is either:
- seriously overloaded (the server does not have enough free CPU time to service you)
- paused with SIGSTOP, or
- stuck in some way (in an infinite loop, or waiting for something else that is unresponsive)
Any of these is a good reason to report the service as unresponsive. For more information, you will usually need to examine the service's logs or use other diagnostic tools to find out the state of the service.
If your program is written to specifically monitor the service, you might want to set the socket in non-blocking mode before using it to connect to the service. That allows you to catch more errors immediately, without waiting for a time-out.
MK
MK
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP