Re: Finding if one is connected

Jens.Toerring_at_physik.fu-berlin.de
Date: 07/19/04


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


Relevant Pages

  • Re: Osama bin Morgen busted - AGAIN!
    ... The lefties at the Daily Kos and Think Progress are ... Kos and Think Progress report Fallon called Petraeus ... News Agency," or "IPS" as the organization bills itself. ...
    (alt.guitar.amps)
  • Re: When I edit an existing photo gallery I cant complete the pro
    ... I am having the same problem after adding a new pic, the Progress box just ... hangs. ... Deleting the Photo Gallery and starting over is the only way I've found to ... > You may want to check out third party album generators, like JAlbum and it's skinnable. ...
    (microsoft.public.frontpage.client)
  • Re: "Runtime error" message box
    ... Any progress on this problem? ... I am in the exact same situation (trying ... to run as a service but it hangs because of the popup). ...
    (microsoft.public.dotnet.languages.vc)
  • Kdenlive
    ... I am using Kdenlive 0.6 from the packman repo. ... The progress gets to 99% with 0 sec remaining, but just hangs. ... have to abort the exporting. ...
    (alt.os.linux.suse)
  • Installing IIS on XP Professional
    ... When I try to install IIS on my XP system, it always just hangs. ... "configuring SMTP services" and never gets anywhere in the ... progress of that. ...
    (microsoft.public.inetserver.iis)