Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » How to check internet availability?
How to check internet availability? [message #44158] Sun, 11 January 2015 14:07 Go to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

do we have some way to check if we are connected to a working network?
It would be nice to have the solution for both windows and linux, but even a dirty solution (using Windows API) only for windows would be ok.

Thanks,
Luigi
Re: How to check internet availability? [message #44159 is a reply to message #44158] Sun, 11 January 2015 14:48 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 610
Registered: August 2007
Location: Turkey
Contributor
Hello Luigi,

The easiest workaround that comes to my mind is trying to connect to a known network or host (such as google) and grabbing the socket errors if any.
İf a socket error occurs, simply check the errno for error number: ENETUNREACH on Linux, and WSAGetLastError() for WSAEHOSTUNREACH on Windows.

On windows, there are also InternetGetConnectedState() and InternetCheckConnection() functions, from Windows 2000 and on.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa38 4702%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/aa38 4346%28v=vs.85%29.aspx

Regards,
Oblivion


[Updated on: Sun, 11 January 2015 14:58]

Report message to a moderator

Re: How to check internet availability? [message #44160 is a reply to message #44159] Sun, 11 January 2015 17:18 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Thank you!

Luigi
Re: How to check internet availability? [message #44162 is a reply to message #44158] Mon, 12 January 2015 08:20 Go to previous messageGo to next message
andreincx is currently offline  andreincx
Messages: 15
Registered: March 2014
Promising Member
Hi,

Another portable solution (using U++):
bool isConnected = IpAddrInfo().Execute('google.com', 80);


Andrei
Re: How to check internet availability? [message #44164 is a reply to message #44162] Mon, 12 January 2015 15:25 Go to previous message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Very good!

thanks,
Luigi
Previous Topic: Print unwanted copy
Next Topic: Context Menu request
Goto Forum:
  


Current Time: Fri Dec 06 15:10:39 CET 2019

Total time taken to generate the page: 0.00815 seconds