Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DNSServiceQueryRecord callback won't do



Olger,

So I feel that the next code should do the same:

    const char* fullname = "machost._afpovertcp._tcp.local.";
    //const char* fullname = "_afpovertcp._tcp.local";
    printf("looking for %s\n", fullname);
    DNSServiceErrorType err;
    DNSServiceRef client = NULL;

err = DNSServiceQueryRecord(&client,0,0,fullname,ns_t_ptr,ns_c_in,query_rep ly,NULL);
if (err != kDNSServiceErr_NoError) {
printf("register returned failure:%d\n", err);
}


    DNSServiceProcessResult(client);
    DNSServiceRefDeallocate(client);

The DNSServiceQueryRecord gives a result for a query :_afpovertcp._tcp.local. (as found in the comment)
(it actually returns an rrtype = 12 not a rrtype = 1)


But it doesn't work for a single service name. (e.g: machost.....) it seems.

The documentation states to use QueryRecord if you have shared services. I am working on a service that could be available multiple times and the rendezvous based client can select on of them (you can make some algorithms which to pick)

It's not clear what you're trying to do. Have you tried using DNSServiceBrowse()? Are you using DNSServiceRegister() to advertise your services?


I use DNSServiceRegister to advertise my services and I need a mechanism to find them back (but there might be more than one of them with the same name

You can't have multiple services with the same name. DNSServiceRegister() will automatically rename your service name if it detects a name conflict. You should pick your own service type, like _olger._tcp, and then browse for that type. Calling DNSServiceBrowse() is equivalent to calling DNSSerivceQueryRecord() and asking for PTR records with the name "_olger._tcp.local."




(id) Looking at the documentation on DNSServiceBrowse, I would say that it gives me all services (as a char* serviceName) that match to the patterns of a servicetype (like _http._tcp or things alike) in a certain domain.
I already know the servicename I am looking for, so a query is more like MyService._http._tcp.local. and do not need to Browse as far as I can see. So Resolv or Query seem to do the job, but according to the documentation you need Query if you expect to find more than 1 MyService._http._tcp.local.

After you browse and discover the list of service names, then you would call DNSServiceResolve() to retrieve the hostname and port number of the service. Calling DNSServiceResolve() is equivalent to calling DNSServiceQueryRecord() two times. Once for the SRV record and once for the TXT record.




Is it possible to have shared services like that ? and how to use QueryRecord to get these ?
Does the DDNS close the connection after the answer or can more answers be expected based on the query at a later time ?

In your example code, you're calling DNSServiceRefDeallocate() immediately after getting the first answer, which closes the connection. You should use select() and put the socket FD in your select() loop so you can receive notifications asynchronously. You should only call DNSServiceRefDeallocate() when you no longer wish to receive notifications.


Yes, I know, it is just a codesnippet put together to show that the same input for Resolve or for Query give different answers (Resolve gives a host + port back of the MyService._http._tcp.local. and Query stays waiting for the answer as it seems not to get the right answer back (or it does not give the right query)

The reason why your DNSServiceQueryRecord() call is failing is because you're asking for PTR records, but you need to be asking for SRV or TXT records. It's easier to just use DNSServiceResolve().


Best Regards,

-Marc






On Nov 1, 2004, at 8:56 PM, Olger Warnier wrote:

Hi List,

I found quite an extensive discussion on the use of DNSServiceQueryRecord
and the callback found in:


Subject: DNSServiceQueryRecord (was Re: FreeBSD and Solaris)
From: Eric Wing <email@hidden>
Date: Thu, 15 Jul 2004 20:50:15 -0700 (PDT)
it is: http://lists.apple.com/archives/rendezvous-dev/2004/Jul/ msg00095.html

But it ends with the remark that the callback doesn't seem to work. On a linux system, I have a situation like that:

When I use DNSServiceResolve(...) and call the DNSServiceProcessResult
(direct or with a select() loop), the service gets resolved and a hostname
+ port number is available.


But I'd like to use the DNSServiceQueryRecord instead with a seperate
select() loop to make it possible keep shared services.
Using DNSServiceQueryRecord with and call the DNSServiceProcessResult
(again direct of with a select() loop), nothing happens.


I use exact the same servicename,type and domain for both and for the
rrtype and rrclass = 1;


In order to use the DNSServiceQueryRecord, do I need to do some
initialization or something ? Or to make my question a bit more generic.
Someone has any suggestions what could solve this ?


Kind Regards,

Olger


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Rendezvous-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/rendezvous-dev/ email@hidden


This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Rendezvous-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/rendezvous-dev/ email@hidden


This email sent to email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. Rendezvous-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/rendezvous-dev/email@hidden

This email sent to email@hidden
References: 
 >DNSServiceQueryRecord callback won't do (From: "Olger Warnier" <email@hidden>)
 >Re: DNSServiceQueryRecord callback won't do (From: Olger Warnier <email@hidden>)
 >Re: DNSServiceQueryRecord callback won't do (From: Marc Krochmal <email@hidden>)
 >Re: DNSServiceQueryRecord callback won't do (From: Olger Warnier <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.