< Previous by Date | Date Index | Next by Date > |
Thread Index |
Hello,
I'm using SVN head of Resiprocate stack and I'm facing a problem using Windows Name Resolution.
I defined WIN32_SYNCRONOUS_RESOLUTION_ON_ARES_FAILURE in the project, so in DnsResult.cxx WSALookupService functions are used to resolve names:
void DnsResult::onDnsResult(const DNSResult<DnsHostRecord>& result)
{
...
#ifdef WIN32_SYNCRONOUS_RESOLUTION_ON_ARES_FAILURE
// Try Windows Name Resolution (not asyncronous)
WSAQUERYSET QuerySet = { 0 };
GUID guidServiceTypeUDP = SVCID_UDP(mPort);
GUID guidServiceTypeTCP = SVCID_TCP(mPort);
HANDLE hQuery;
QuerySet.dwSize = sizeof(WSAQUERYSET);
QuerySet.lpServiceClassId = mTransport == UDP ? &guidServiceTypeUDP : &guidServiceTypeTCP;
QuerySet.dwNameSpace = NS_ALL;
QuerySet.lpszServiceInstanceName = (char *)mTarget.c_str();
if(WSALookupServiceBegin(&QuerySet, LUP_RETURN_ADDR, &hQuery) == 0)
{
DWORD dwQuerySize = 256; // Starting size
int iRet = 0;
bool fDone = false;
LPWSAQUERYSET pQueryResult = (LPWSAQUERYSET) new char[dwQuerySize];
while(iRet == 0 && pQueryResult)
{
iRet = WSALookupServiceNext(hQuery, 0, &dwQuerySize, pQueryResult);
...
If mTarget is the host name (without DNS suffixes) on which my applicaton is running, then WSALookupServiceNext() fails and WSAGetLastError is 10108.
I changed onDnsResult() method using SVCID_HOSTNAME as service class id (see below) and in this way I'm able to resolve host names:
void DnsResult::onDnsResult(const DNSResult<DnsHostRecord>& result)
{
...
#ifdef WIN32_SYNCRONOUS_RESOLUTION_ON_ARES_FAILURE
// Try Windows Name Resolution (not asyncronous)
WSAQUERYSET QuerySet = { 0 };
HANDLE hQuery;
QuerySet.dwSize = sizeof(WSAQUERYSET);
GUID guidServiceTypeHostName = SVCID_HOSTNAME;
QuerySet.lpServiceClassId = &guidServiceTypeHostName;
QuerySet.dwNameSpace = NS_ALL;
QuerySet.lpszServiceInstanceName = (char *)mTarget.c_str();
...
What is your opinion regarding this change?
Is that correct?
Thanks and regards,
Dario.
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.0/366 - Release Date: 15/06/2006