Skip to content

Instantly share code, notes, and snippets.

@eahydra
Created September 19, 2012 05:14
Show Gist options
  • Save eahydra/3747803 to your computer and use it in GitHub Desktop.
Save eahydra/3747803 to your computer and use it in GitHub Desktop.
network change 2
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