Re: Reading a string from a socket
Re: Reading a string from a socket
- Subject: Re: Reading a string from a socket
- From: Daniel Smith <email@hidden>
- Date: Fri, 18 Jan 2008 17:15:28 -0600
On Jan 18, 2008, at 4:30 PM, Chris Parker wrote:
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@hidden> 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.
I must have tried that, too, but it was awhile ago and I don't recall
what happened. I'll investigate and let you know.
—Dan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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