SOL9 Sample: IPAddressChangeNotifier

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * IPAddressChangeNotifier.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2008/10/10
//

#include <sol\WSAInitializer.h>

#include <sol\net\IPAddressChangeNotifier.h>

//..\cc.bat IPAddressChangeNotifier.cpp

/*
 * Simple application to see the effect of Windows NotifyAddrChange API. 
 * You can easily change this to Windows Application by defining WinMain 
 * instead of main.
 */

//int APIENTRY WinMain(HINSTANCE progIns, HINSTANCE prevIns, 
//       LPSTR cmdLine, int cmdShow)
int _tmain(int argc, TCHAR** argv)

{
  WSAInitializer initializer;

  try {

    IPAddressChangeNotifier notifier(GetCurrentThreadId());
    notifier.start();

    MSG msg;
    
    while (GetMessage(&msg, 0, 0, 0)) {
      if (msg.message == WM_IPADDRESS_CHANGE) {
        if (msg.wParam == 1) {
          printf("Connected to Internet\n");
        }
        if (msg.wParam == 0) {
          printf("Disconnected from Internet\n");
        }
      }
    }
    /*
    while (1) {
      Sleep(10000);
    }
    notifier.stop();
    */

  } catch (int err) {
    printf("Exception: %d\n", err);
  } catch (...) {

  }
  return 0;

}




Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.