• 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:20:14 +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)
{
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);
}
}
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

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: mDNS Service Discovery and Text Record access
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: Convert HTML to plain text
  • Next by Date: Custom Shape Window and standardWindowButton
  • Previous by thread: Re: binding uncaught exception
  • Next by thread: Re: mDNS Service Discovery and Text Record access
  • Index(es):
    • Date
    • Thread