Mailing Lists: Apple Mailing Lists

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

Question about retrieving port numbers



Hello all,

I am new to Rendezvous and am trying to whip up a demo to show internally in my company.

I've adapted the code in mDNSPosix/Client.c to some internal code and have it successfully printing out the services that it finds.

Currently, the code only prints out the name, service type, and domain and tries to print out the IP and Port. The ip and port and nowhere near the values that I registered the service with so I can only assume I'm doing something wrong. Can you help me pinpoint that?

Thank you for your time,

_ michael


SYMPTOM ------- A service that I registered using this commandline:

./mDNSProxyResponderPosix 10.0.0.197 computer "Rendezvous Test" _testservice._tcp 1666

gives me this output:

*** Found name = 'Rendezvous Test', type = '_testservice._tcp.', domain = 'local.', IPAddress = '15.82.101.110', port = '25701'

I would have expected:

*** Found name = 'Rendezvous Test', type = '_testservice._tcp.', domain = 'local.', IPAddress = '10.0.0.197', port = '1666'


CODE
----
void BrowseCallback(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord)
// A callback from the core mDNS code that indicates that we've received a
// response to our query. Note that this code runs on the main thread
// (in fact, there is only one thread!), so we can safely printf the results.
{
domainlabel name;
domainname type;
domainname domain;
char nameC [MAX_DOMAIN_LABEL+1]; // Unescaped name: up to 63 bytes plus C-string terminating NULL.
char typeC [MAX_ESCAPED_DOMAIN_NAME];
char domainC[MAX_ESCAPED_DOMAIN_NAME];
const char *state;


	(void)m;		// Unused
	(void)question;	// Unused

	mDNSv4Addr ip = answer->rdata->u.ip;
	char buffer[256];
	sprintf(buffer, "%d.%d.%d.%d", ip.b[0], ip.b[1], ip.b[2], ip.b[3]);

DeconstructServiceName(&answer->rdata->u.name, &name, &type, &domain);

    ConvertDomainLabelToCString_unescaped(&name, nameC);
    ConvertDomainNameToCString(&type, typeC);
    ConvertDomainNameToCString(&domain, domainC);

// If the TTL has hit 0, the service is no longer available.
if (!AddRecord) {
state = "Lost ";
} else {
state = "Found";
}
fprintf(stderr, "*** %s name = '%s', type = '%s', domain = '%s', IPAddress = '%s', port = '%d'\n",
state, nameC, typeC, domainC, buffer, answer->rdata->u.srv.port);
}
_______________________________________________
rendezvous mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/rendezvous
Do not post admin requests to the list. They will be ignored.





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.