Is there any way to be notified by windows OS when a new connection is available, in a Java program (using JNI)? At the moment the only way I have to check this is by polling a function that tries to download a webpage. If the download success and no exception is thrown, then I can guess there is Internet connectivity.
However, a better solution could be this one:
- On program start, check Internet connectivity
- If no internet connection is available, "register" for windows network notification and WAIT()
- User connects to Internet, Windows os notifies the Java machine=> the threads wakes up
- Do some stuff....