Re: CFHost and Rendezvous names
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