On Thu, Dec 4, 2008 at 1:22 AM, Ken Tozier <[EMAIL PROTECTED]> wrote:
> Thanks Mike
>
> Still trying to get my head around this stuff, but here's how I interpret
> what I need to do...
>
> Create a connection to MySQL
>        #define DEFAULT_MYSQL_PORT_NUMBER       3306
>        socket  = [[NSSocketPort alloc] initRemoteWithTCPPort:
> DEFAUT_MYSQL_PORT_NUMBER host: @"some host"];
>
> Register as the delegate of the port
>        [socket setDelegate: self];
>
> Add to run loop
>        [[NSRunLoop mainRunLoop] addPort: socket forMode:
> NSDefaultRunLoopMode];
>
> Here's where I lose the thread. As the delegate, do I need to implement
>        - (void) handlePortMessage:(NSPortMessage *) inPortMessage
>
> Or, because I'm dealing with something that has no concept of NSPortMessage,
> do I need to use NSInput/NSOutput streams?

Yes. NSPort is part of the Distributed Objects system. It's possible
to use NSPort on its own, but you must use it to talk to another
process which also uses NSPort. It is *possible* to use NSSocketPort
to create a socket which you then communicate with using other
techniques, but you can't use NSSocketPort directly to talk to a
non-Cocoa app.

> If so, where in the process do I
> squeeze those in?

Just replace the above code with code that creates a pair of NSStreams
to your target.

> Also very confused about which stream I would receive
> replies from MySQL (assuming I could successfully connect) If I send a
> message through an NSOutputStream, wouldn't MySQL send the reply back
> through the same stream? I don't see how it could do otherwise as it has no
> idea who the client app is, or how to connect and build it's own NSOutput
> stream with which to reply.

You'll have a pair of NSStreams which wrap the same socket. When you
write to your NSOutputStream the data will be written to the socket,
and when the other end writes to the socket, it will appear on your
NSInputStream.

Mike
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to