On Dec 6, 2008, at 6:45 PM, Andrew Farmer wrote:

This is incorrect. A "connection refused" error in this context means that you're either trying to connect to a host/port which is not configured to accept a connection, or the host is behind a firewall which blocks incoming connections. In this case, it's probably the former. But what you're probably running into here is simply the fact that MySQL doesn't accept TCP connections at all by default - instead, it uses a UNIX domain socket in either /var/tmp/ mysql.sock or /tmp/mysql.sock.

The host and client are both on my laptop so I don't think the config/ firewall stuff applies. I got my custom socket class working and was able to connect, at least up to receiving the handshake packet, using TCP. Not sure what Apple is doing in the guts of NSSocketPort, but my class is able to connect and fetch the handshake. When I try the same thing with NSSocketPort's file descriptor, no go.

More to the point, though, why are you trying to reimplement the MySQL client library? You haven't even gotten to the wire protocol yet, which I guarantee is going to pose you even more problems than just connecting to the server. If you're just concerned about having to include the library, you can link statically against the libmysqlclient library to avoid having to drag the shared library around with you. (Note, however, that libmysqlclient is licensed under the GPL, so you'll need to talk to Sun if you want to use it in non-free software.)

I love a challenge :) It's an interesting problem and I'm learning how to use sockets. I wouldn't have even thought of bypassing the library, but I stumbled across this really cool flash library that connects to MySQL completely via sockets (http://asql.mooska.pl/release/srcview/) and thought it would be cool to do something like that in Cocoa.

The MySQL protocol isn't all that difficult. I found a good resource here (http://forge.mysql.com/wiki/ MySQL_Internals_ClientServer_Protocol) The trickiest part seems to be scrambling the user password with the seed MySQL sends in the handshake. I already wrote a nice, simple packet parser to handle the different types of MySQL messages and am working my way through the password stuff.

What I'm writing will be installed on about 50 to 100 machines and I have no interest in installing the client lib on all of them. I actually got some code working with the client lib but it broke as soon as it was installed on a different architecture (PowerPC) and OS version (10.4 vs 10.5) These four combinations of OS and processors are a given and I can't do anything about that. Each configuration requires a client lib specifically compiled for it and I don't want to support 4 different versions of my app or the support calls when they do a clean install or an upgrade and suddenly my app stops working. With my own sockets, I'll only ever have to worry about MySQL protocol changes which are much less frequent than MySQL updates.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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