hi all,i have a problem with Service Discovery Function WSALookupServiceBegin(),i get Bad Address error from WSAGetLastError(), i initilize queryset like this:
WSAQUERYSET query;
SecureZeroMemory(&query,
sizeof(WSAQUERYSET));query.dwNameSpace = NS_BTH;
// query.lpBlob = NULL;query.lpServiceClassId = &rfcomm;
query.dwNumberOfCsAddrs = 0;
//query.lpszContext = (LPWSTR) converted_address;
and then pass it to WSALookupServiceBegin()...if i comment out // query.dwNameSpace = NS_BTH; i get another error: WSASERVICE_NOT_FOUND...can someone tell me how i can fix this i bunched code together here:
// device doscovery start here
WSALookupServiceBeginW(&wsaq, LUP_RETURN_NAME | LUP_CONTAINERS | LUP_RETURN_ADDR | LUP_FLUSHCACHE | LUP_RETURN_TYPE | LUP_RETURN_BLOB | LUP_RES_SERVICE, &hLookup)
do
{temp = WSALookupServiceNextW (hLookup, LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults);
if(pwsaResults ->dwNumberOfCsAddrs < 1){
SecureZeroMemory(converted_address,
sizeof (wchar_t)); return 0;};
DWORD strSize =
sizeof converted_address; // bad! bad! bad!WSAAddressToStringW(pwsaResults ->lpcsaBuffer ->RemoteAddr.lpSockaddr,
pwsaResults ->lpcsaBuffer ->RemoteAddr.iSockaddrLength,
NULL,
converted_address,
&strSize);
////////////////////////////////////////////////////////////////////////////////////// /////////////////// Device Discovery Finished ///////////////////////////////////////std :: wcout << converted_address <<
" device found " << std :: endl; /////////////////// Service Search Starts Here ///////////////////////////////////////GUID rfcomm;
rfcomm.Data1 = RFCOMM_PROTOCOL_UUID16;
// what to search for
HANDLE sHandle;
union{
CHAR s_buffer[5000];
double __unused;};
LPWSAQUERYSET p_query = (LPWSAQUERYSET)s_buffer;
SecureZeroMemory(p_query,
sizeof(WSAQUERYSET));DWORD sdwSize =
sizeof s_buffer;WSAQUERYSET query;
SecureZeroMemory(&query,
sizeof(WSAQUERYSET));query.dwNameSpace = NS_BTH;
// query.lpBlob = NULL;query.lpServiceClassId = &rfcomm;
query.dwNumberOfCsAddrs = 0;
//query.lpszContext = (LPWSTR) converted_address;
// MSDN (Bluetooth and WSALookupServiceBegin for Service Discovery) sais: must be a string converted using wsaaddresstostring function int temp2 = 0; std :: cout << " temp2 initilized to " << temp2 << std :: endl;temp2 = WSALookupServiceBeginW(&query, LUP_FLUSHCACHE |
LUP_RETURN_NAME|
LUP_RETURN_TYPE|
LUP_RETURN_COMMENT,
&sHandle);
// if(temp2 == SOCKET_ERROR) // std :: cout << WSAGetLastError() << " last eror code " << std :: endl;ErrorCodes(temp2);

Bluetooth Service Discovery Problem
mzahmed
pls check the following link for info on more appropriate newsgroups/forums for questions of this type
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=286724&SiteID=1
Srikanth Bogadapati