Re: Finding if one is connected
Jens.Toerring_at_physik.fu-berlin.de
Date: 07/19/04
- Next message: Ashutosh: "Re: Finding if one is connected"
- Previous message: Ashutosh: "Re: Finding if one is connected"
- In reply to: Ashutosh: "Re: Finding if one is connected"
- Next in thread: Ashutosh: "Re: Finding if one is connected"
- Reply: Ashutosh: "Re: Finding if one is connected"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Jul 2004 18:45:47 GMT
Ashutosh <ashusharma1980@yahoo.co.uk> wrote:
> The problem is that when I do a 'connect()', for some IPs, it just hangs,
> for some it returns in some time with "No route to host" (perror output).
> Is there some way to put a timeout on "connect()". If I do a 'fcntl(sockfd,
> F_SETFL, O_NONBLOCK);' on the socket, it always returns with "connect:
> Operation now in progress" (perror output)
You can call e.g. sleep() with the maximum time you're prepared to
wait for the server before calling connect(). When you get a SIGALRM
before connect() had success errno will be set to EINTR (just make
sure you handle the SIGALRM signal properly in order not to get
killed by it).
Regards, Jens
-- \ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de \__________________________ http://www.toerring.de
- Next message: Ashutosh: "Re: Finding if one is connected"
- Previous message: Ashutosh: "Re: Finding if one is connected"
- In reply to: Ashutosh: "Re: Finding if one is connected"
- Next in thread: Ashutosh: "Re: Finding if one is connected"
- Reply: Ashutosh: "Re: Finding if one is connected"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|