- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: connect
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
тАО03-18-2010 05:40 AM
тАО03-18-2010 05:40 AM
connect
I have met the following problem in managing "connect" function.
To manage the case in which the remote host is not available, I have written the following code:
alarm(1);
err = connect(....);
alarm(0);
so, if the remote node is not available the connect will be interrupted from incoming SIGALRM and the err variable is set to 4.
Now, in some cases such a mechanism doesn't work and the connect terminates only when its time out expires (errno = 238 - Connection timed out)
Which could be the reason?
Do you see any weakness in this procedure?
Thanks in Advance
Giuseppe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2010 05:54 AM
тАО03-18-2010 05:54 AM
Re: connect
What you have shown doesn't reveal the signal handler code. For that matter, the 'connect()' normally blocks (waits) until satisfied. You could use a non-blocking connection and periodically retry until you are interrupted or achieve a successful connection.
See the manpages for 'connect(2)' for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2010 06:19 AM
тАО03-18-2010 06:19 AM
Re: connect
sigemptyset(&signalAction.sa_mask);
signalAction.sa_flags = 0;
signalAction.sa_handler = SigExit;
....
sigaction(SIGALRM,&signalAction, NULL);
where:
void SigExit(int sig)
{
switch(sig)
{
case SIGALRM:
return;
break;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2010 06:55 AM
тАО03-18-2010 06:55 AM
Re: connect
I think you want select(), with the timeout set to one second.
I would avoid a signal handler in this procedure, the select function is what I'd go with.
Best,
Dave Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2010 04:29 PM
тАО03-18-2010 04:29 PM
Re: connect
Is this a single, or a multi-threaded program?