Created
September 19, 2012 05:14
-
-
Save eahydra/3747803 to your computer and use it in GitHub Desktop.
network change 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void WaitForNetworkChnages() | |
{ | |
WSAQUERYSET querySet = {0}; | |
querySet.dwSize = sizeof(WSAQUERYSET); | |
querySet.dwNameSpace = NS_NLA; | |
HANDLE LookupHandle = NULL; | |
WSALookupServiceBegin(&querySet, LUP_RETURN_ALL, &LookupHandle); | |
DWORD BytesReturned = 0; | |
WSANSPIoctl(LookupHandle, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &BytesReturned, NULL); | |
WSALookupServiceEnd(LookupHandle); | |
} | |
void Test() | |
{ | |
WSAData data = {0}; | |
WSAStartup(MAKEWORD(2, 0), &data); | |
int i = 0; | |
while(1) | |
{ | |
printf("BeginWait %d\n", i++); | |
WaitForNetworkChnages(); | |
printf("EndWait\n"); | |
} | |
WSACleanup(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment