[gnome-network]Re: network://



On Thu, 2003-09-11 at 17:04, Sean Middleditch wrote:
> *rushes off to look at gmdns*
> 
> The docs are rather lacking, and a quick (i.e., < 5 minutes) perusal of
> the code didn't answer: is this only a resolver?  It looks as tho it has
> some service registration code, but I'm not quite sure what it's doing
> (I'm not too familiar with the glib api, sadly).

Docs? Its just something I was playing with and checked in to cvs :)

It can both advertise and resolve. To advertise a service you do
something like:
GmDNSService* svc = gmdns_service_new ("myserver", "http", NULL, NULL);
gmdns_service_set_address (svc, ip, port)
gmdns_service_start (svc);

Resolution is asynchronous, so I used gobject signals to return answers.
To query for http services you'd do something like:
GmDNSServiceQuery* q = gmdns_service_query_new ("http");
g_signal_connect (q, "answer", (GCallback)answer_callback, NULL);
gmdns_service_query_start (q);

where answer_callback is something like:
static void answer_callback (GmDNSServiceQuery* query, const
GmDNSServiceQueryAnswer* answer, gpointer data) {
	if (answer->answer_type == SERVICE_QUERY_ANSWER_FOUND) {
		g_message ("server %s found at %s:%d", answer->name,
			inet_ntoa (answer->ip), answer->port);
	}
}

the callback also gets notified of changes to services and when services
go away and is also supplied "extra" information - which in the case of
http SRV advertisments contains things like the path. Its implemented as
an ugly hash table hacked into the TXT record iirc, so I expose it as a
GHashtable :)
> 
> If it is a server, then does this mean that if a GNOME app using this
> library is advertising a service, no non-GNOME app can also run an MDNS
> advertised service?  I would have thought the system would need a single
> centralized MDNS daemon for responding, with a "standardized" API.  I'm
> not all that up-to-date on multicast networking, tho.  (That being a
> reason I haven't yet got much past the research phase.  ;-)

This doesn't include a server but has applications advertise themselves.
I haven't had any problems running multiple apps at once. I do think
that a gnome-wide responder would be better since responders really
should be watching for things like interfaces coming up and down to
readvertise on new interfaces transparently, but I don't think that
would cause any conflict with other responders on the system.

Now I just need to make MOL work on my system again so I can keep
hacking on this. I have a bunch of changes I need to finish and check in
that I was half way through when my laptop broke last.

Ian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]