Click to See Complete Forum and Search --> : Check the internet connection state


Athropos
February 5th, 2003, 12:47 PM
Hello,

I would like to be able to detect if the computer is connected to Internet. I've tried InternetGetConnectedState() from wininet, but I always get TRUE, nethertheless I'm connected or not. :confused:

I would like my application to check pop3 accounts, but if the computer is not connected, there is a hang (big timeout when trying to connect).

Thanks.

Bengi
February 6th, 2003, 05:30 PM
check this source:
http://spiff.tripnet.se/~iczelion/files/Welcome2Net.zip

its i Win32Asm, but there isn't much diff, actually they are the same, just diff syntax!
have fun translating

Athropos
February 6th, 2003, 11:55 PM
Thanks, dont worry I've got no pb with asm and it's the same API.

filthy_mcnasty
February 7th, 2003, 12:27 AM
to translate......(even though i'm sure you can do it)

WSADATA wsadata;
WSAStartup(0x101, &wsadata);
if(gethostbyname("www.microsoft.com") != NULL)
We_are_online();
else
Offline();
WSACleanup();


this is one method but also you might want to try using
gethostname();
and then gethostbyname(); with information returned from the first one. then you can enumerate the IP list returned and check against common local ips *127.0.0.1 or home network ones*

AdaraCD
February 9th, 2003, 01:31 AM
BOOL InetIsOffline(
DWORD dwFlags,
);

or

DWORD RasEnumConnections(
LPRASCONN lprasconn, // buffer to receive connections data
LPDWORD lpcb, // size in bytes of buffer
LPDWORD lpcConnections // number of connections written to buffer
);