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? If so, where in the process do I squeeze those in? 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.

On Dec 4, 2008, at 12:23 AM, Michael Ash wrote:

NSConnection is for distributed objects and nothing else. Despite the
name it is *not* a general-purpose IPC mechanism. As such, it only
works for talking to other Cocoa programs (and only if they're
prepared to accept distributed objects connections), so using it for
MySQL is Right Out.

If you create a pair of NSStreams with a socket then it provides you
with essentially a direct wrapper for the BSD socket stuff. (It is so
direct that the -read: and -write: methods have the exact same
semantics as the read() and write() functions despite not being
documented this way for at least one or two OS revisions.) I've found
NSStream to be the most convenient way for dealing with sockets in a
Cocoa app in most situations, but you can certainly feel free to hit
the BSD layer or use one of the other free sockets wrappers if you
prefer.

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/kentozier%40comcast.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

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