• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
mDNS Service Discovery and Text Record access
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mDNS Service Discovery and Text Record access


  • Subject: mDNS Service Discovery and Text Record access
  • From: Alexander Hartner <email@hidden>
  • Date: Wed, 18 Apr 2007 23:16:16 +0100

I am trying to discover a service published via mDNS. This is my call back function. My problem is that I have so far not been able to access the TextRecords attributes. It seems that the size of the string is behaving very oddly.

void resolveCallBack (DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context )
{
if (errorCode == kDNSServiceErr_NoError) 
{ 
NSLog(@"FULLNAME : %s \n",fullname);
NSLog(@"HOST : %s \n",hosttarget);
NSLog(@"PORT : %i \n",port);
NSLog(@"TXT  : %s \n",txtRecord);

uint8_t valueLength;
const char * value = TXTRecordGetValuePtr(txtLen,txtRecord,"hostUrl",&valueLength);
NSLog(@"SIZE OF CHAR : %i \n",sizeof(char));
NSLog(@"URL  : >%s< (%i)\n",value,valueLength);
char * hostUrl[valueLength+1];
bcopy(value,hostUrl, valueLength );
hostUrl[valueLength] = '\0';
NSLog(@"Host : >%s< \n",hostUrl);
} 
else 
{
NSLog(@"ResolveCallBack returned error : %d\n", errorCode); 
}
}

I change the code above as follows:

bcopy(value,hostUrl, valueLength );
hostUrl[1] = '\0';
NSLog(@"Host : >%s< \n",hostUrl);

But what I ended up was 4 characters being printed. I know that the resulting string should be 34 characters long, but it seems that the index at which I insert the termination character is not set correctly. Index 1 resulted in character 4, index 2 in 8 etc. I though it must be a problem with the size of char, but sizeof return 1 byte and bcopy should copy bytes.

I tried to search on the web for an example of doing this, but didn't find anything useful. I am sure I am just doing something incredibly silly.

Any help is greatly appreciated.
Alex 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • RE: mDNS Service Discovery and Text Record access
      • From: "Jamie Wood" <email@hidden>
  • Prev by Date: Help on attaching network interfaces
  • Next by Date: RE: mDNS Service Discovery and Text Record access
  • Previous by thread: Help on attaching network interfaces
  • Next by thread: RE: mDNS Service Discovery and Text Record access
  • Index(es):
    • Date
    • Thread