Re: Problem faced while using Native WLAN API.
- From: "Yi Lu [MSFT]" <yilu@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 2 Mar 2007 11:59:29 -0800
There is a limit on how many handles a process can open.
You may want to review your code and check handle leak.
For example, it seems that you don't close a handle if an exception is thrown.
Thanks,
Yi
--
This posting is provided "AS IS" and confers no rights. Use of sample scripts is subject to the terms provided at http://www.microsoft.com/info/cpyright.htm.
<marimuthu.pesit@xxxxxxxxx> wrote in message news:1172816540.617588.60950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
In my application, I am making use of native WLAN api's.
The problem arises when I plug and unplug my WiFi adapter connected to
my Laptop (I dont have a build in WiFi adapter in my laptop)
continously for about 5 to 6 times,
the function WlanOpenHandle( ) return a error code 1220 which is
ERROR_REMOTE_SESSION_LIMIT_EXCEEDED "An attempt was made to establish
a session to a network server, but there are already too many sessions
established to that server." as mentioned in MSDN.
But this issue doesnt arise if i plug and unplug the external WiFi
adapter once or twice.
I have attached the code for your reference.
Please give me a solution.
BOOL CWireless::EnumDevices(ALL_DEVICE_INFO & pDeviceInfo)
{
ODS("CWireless::EnumDevices");
PWLAN_INTERFACE_INFO_LIST pAvailableInterfaces = NULL;
DWORD dwErrorCode = ERROR_SUCCESS;
HANDLE hClientHdl = NULL;
DWORD dwVersion = 0;
pDeviceInfo.NoOfDevices = 0;
try
{
if ((dwError = WlanOpenHandle(WLAN_API_VERSION, NULL, // reserved
&dwVersion, &hClientHdl)) == ERROR_SUCCESS)
{
WlanEnumInterfaces(hClientHdl, NULL, &pAvailableInterfaces);
// This could happen if the WLAN Auto Config service is stopped
if(NULL == pAvailableInterfaces)
{
ODS("GetEnumDevices failed");
LogMessageInfo(WL_INFORMATION, "Wireless interfaces not
available", NULL, NULL, NULL);
//close handle
WlanCloseHandle(hClientHdl,
NULL // reserved
);
return FALSE;
}
if(pAvailableInterfaces->dwNumberOfItems >0)
{
CString strInterface;
pDeviceInfo.NoOfDevices = pAvailableInterfaces->dwNumberOfItems;
for (int nCount=0;nCount<pAvailableInterfaces-
dwNumberOfItems;nCount++){
strInterface = pAvailableInterfaces-
InterfaceInfo[nCount].strInterfaceDescription;strcpy(pDeviceInfo.chAdaptersName[nCount] , strInterface);
}
// Free all memory allocated by Wlan APIs
WlanFreeMemory(pAvailableInterfaces);
WlanCloseHandle(hClientHdl,
NULL // reserved
);
hClientHdl = NULL;
pAvailableInterfaces = NULL;
}
}
else
{
// Free all memory allocated by Wlan APIs
WlanFreeMemory(pAvailableInterfaces);
WlanCloseHandle(hClientHdl,
NULL // reserved
);
ODS("GetEnumDevices failed");
return FALSE;
}
return TRUE;
}
catch(...)
{
ODS("Exception at CWireless::EnumDevices");
}
return FALSE;
.
- References:
- Problem faced while using Native WLAN API.
- From: marimuthu . pesit
- Problem faced while using Native WLAN API.
- Prev by Date: Re: socket inheritance & LSP filter
- Next by Date: CreateNPPInterface Problem
- Previous by thread: Problem faced while using Native WLAN API.
- Next by thread: RE: Problem faced while using Native WLAN API.
- Index(es):
Loading