cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: Connected ?

From: Andrew Francis <locust_at_familyhealth.com.au>
Date: Tue, 15 Jul 2003 00:22:42 +0800

On Mon, Jul 14, 2003 at 10:37:41AM +0100, Paul Johnson wrote:
> Fair point. I'm on win32 trying to talk to a unix server across an internet
> connection. curl has initalised successfully and returned with no errors,
> but I need to make my own program stop right there if an auto-dial flag
> isn't set and theres no internet connection.

Take a look at InternetGetConnectedState and InternetDial, in
<wininet.h>. You want something along these lines:

DWORD inetInfo;
if(InternetGetConnectedState(&inetInfo, 0) == FALSE) {
        if(!weAreAllowedToConnect)
                bombout(); // not connected and not allowed to fix that

        if(InternetDial(0, 0, 0, &inetInfo, 0) != ERROR_SUCCESS)
                bombout(); // we tried to dial up but couldn't
 }

I've pretty much paraphrased this from some source I have lying around
but I wrote it eons ago and don't remember what all of those zeroes mean,
so I wouldn't recommend using this blindly without going to the docs first.

You want to do this _before_ initialising WinSock. (I believe
curl_easy_init() takes care of that these days, so do this before
hitting curl).

Cheers

-- 
Andrew Francis
Software Developer
Family Health Software
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
Received on 2003-07-14

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET