FROM : Chris Parker
DATE : Fri Jan 18 23:30:28 2008
On Jan 18, 2008, at 2:17 PM, Daniel Smith wrote:
> On Jan 18, 2008, at 2:01 PM, Hamish Allan wrote:
>
>> On Jan 18, 2008 7:07 PM, Daniel Smith <<email_removed>> wrote:
>>
>>> Any suggestions? Can I make this code work? Or should I be
>>> trying a
>>> different approach (note that I don't want to change the server in
>>> any way)? Perhaps I'd be better off using lower-level APIs?
>>
>> Take a look at http://developer.apple.com/documentation/Cocoa/Conceptual/Streams/Articles/NetworkStreams.html
>>
>> Hamish
>
> Thanks for that suggestion. I had looked into
> NSStream:getStreamsToHost previously, and forgot to mention why I
> avoided it: I'm using Bonjour to locate the server, which gives me
> an NSNetService. The address information I get from
> NSNetService:addresses is already encoded as a sockaddr struct.
> While my example didn't demonstrate it, what I was ultimately trying
> to use is the NSSocketPort:initRemoteWithProtocolFamily:...
> constructor, because it takes a sockaddr as input. Alternatively, I
> would need to be able to map from the sockaddr to an IP address and
> port in a format that NSStream:getStreamsToHost or some other method
> understands.
If you're using NSNetServices to discover hosts, can't you just use
this method:
- (BOOL)getInputStream:(NSInputStream **)inputStream outputStream:
(NSOutputStream **)outputStream;
defined in NSNetServices.h to pick up the streams? This completely
forgoes any resolution and just fills in the streams parameters for you.
.chris
--
Chris Parker
Cocoa Frameworks
Apple Inc.
DATE : Fri Jan 18 23:30:28 2008
On Jan 18, 2008, at 2:17 PM, Daniel Smith wrote:
> On Jan 18, 2008, at 2:01 PM, Hamish Allan wrote:
>
>> On Jan 18, 2008 7:07 PM, Daniel Smith <<email_removed>> wrote:
>>
>>> Any suggestions? Can I make this code work? Or should I be
>>> trying a
>>> different approach (note that I don't want to change the server in
>>> any way)? Perhaps I'd be better off using lower-level APIs?
>>
>> Take a look at http://developer.apple.com/documentation/Cocoa/Conceptual/Streams/Articles/NetworkStreams.html
>>
>> Hamish
>
> Thanks for that suggestion. I had looked into
> NSStream:getStreamsToHost previously, and forgot to mention why I
> avoided it: I'm using Bonjour to locate the server, which gives me
> an NSNetService. The address information I get from
> NSNetService:addresses is already encoded as a sockaddr struct.
> While my example didn't demonstrate it, what I was ultimately trying
> to use is the NSSocketPort:initRemoteWithProtocolFamily:...
> constructor, because it takes a sockaddr as input. Alternatively, I
> would need to be able to map from the sockaddr to an IP address and
> port in a format that NSStream:getStreamsToHost or some other method
> understands.
If you're using NSNetServices to discover hosts, can't you just use
this method:
- (BOOL)getInputStream:(NSInputStream **)inputStream outputStream:
(NSOutputStream **)outputStream;
defined in NSNetServices.h to pick up the streams? This completely
forgoes any resolution and just fills in the streams parameters for you.
.chris
--
Chris Parker
Cocoa Frameworks
Apple Inc.
| Related mails | Author | Date |
|---|---|---|
| Daniel Smith | Jan 18, 20:07 | |
| Hamish Allan | Jan 18, 21:01 | |
| Daniel Smith | Jan 18, 23:17 | |
| Chris Parker | Jan 18, 23:30 | |
| Daniel Smith | Jan 19, 00:15 |






Cocoa mail archive

