• 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
Re: CFHost and Rendezvous names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFHost and Rendezvous names


  • Subject: Re: CFHost and Rendezvous names
  • From: Jeremy Wyld <email@hidden>
  • Date: Mon, 11 Apr 2005 09:30:13 -0700

The resulting CFDataRef's of a a CFHost lookup are struct sockaddr's. This is true when using CFNetService to perform a lookup. Where CFNetService will fill in the port of the struct for the service, CFHost does not. You will need to do this. Simply make a mutable copy of the CFDataRef and change the port as required.

E.g.

CFMutableDataRef address = CFDataCreateMutableCopy (kCFAllocatorDefault, 0, original);

switch (((struct sockaddr*)CFDataGetBytePtr(address))->sa_family) {

case AF_INET:
((struct sockaddr_in*)(CFDataGetMutableBytePtr(address)))- >sin_port = htons(port);
break;


case AF_INET6:
((struct sockaddr_in6*)(CFDataGetMutableBytePtr(address)))- >sin6_port = htons(port);
break;


    default:
        fprintf(stderr, "Unknown address family!\n");
        break;
}


Like I said though, this is only needed for CFHost results and not CFNetService results.


jeremy



On Apr 9, 2005, at 5:34 AM, Tomas Franzén wrote:

On Apr 8, 2005, at 19:18, Marc Krochmal wrote:

It seems to work fine for me.  Can you try it with CFHostSample...


Thanks for pointing out that sample code - I didn't know it existed.
I tried it and it indeed works. My problem seems to be the stupid way I convert the resulting sockaddr to the proper format (making IPv6 addresses fail).
What's the proper way of somehow converting the resulting 'sockaddr' to a 'sockaddr_in', to use with CFSocket?
Sorry if it's a basic question, but all these structs confuse me. :-)


Thanks!

Tomas Franzén
Lighthead Software
http://www.lightheadsw.com/

I'm listening to U2 - Trip Through Your Wires
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com


This email sent to email@hidden


_______________________________________________ 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
References: 
 >CFHost and Rendezvous names (From: Tomas Franzén <email@hidden>)
 >Re: CFHost and Rendezvous names (From: Marc Krochmal <email@hidden>)
 >Re: CFHost and Rendezvous names (From: Tomas Franzén <email@hidden>)

  • Prev by Date: Re: CFSocket on Windows?
  • Next by Date: Re: CFSocket on Windows?
  • Previous by thread: Re: CFHost and Rendezvous names
  • Next by thread: UDP packets not delivered from USB modem
  • Index(es):
    • Date
    • Thread