On Dec 5, 2008, at 10:18 PM, Edward Diener wrote:
> To what does the "service name" refer ? Are there valid service
> names in some RFC which explains the TCP/IP address syntax, or is
> this strict ly a MySql extension to the TCP/IP address syntax ?
You can probably find a list of official service names at http://iana.org/
but the list that matters is the "services" file on your machine.
It's in /etc on most Unix type machines, including OS X. On Windows,
it was historically in c:\windows, but in NT-derived systems, it's
buried in c:\windows\system32\drivers\etc.
The services file is a plain text file mapping service names to port
numbers. You may already be familiar with the hosts file, which is
This file will usually have several hundred service definitions in it,
covering all the common ports. I just checked two machines, one Linux
and one OS X, and both map the service 'mysql' to 3306 for instance.
So, you could give this for the address parameter: my.server.com:mysql
The advantage of this way of doing things is that you could then
change /etc/services to change the port without recompiling the
program. This approach makes more sense when there is no reasonable
default, or you're adding a custom service name:
my.server.com:altmysql with the altmysql port being, say 3307.
> In my code I ned to connect to a MySql server that is not using the
> standard 3306 port number but rather an SSL port and am trying to
> understand whether I need to add a hardcoded port number or can use
> some sort of generic MySql service name.
If your alternate port is going to stay the same effectively forever,
or you don't mind changing the code and rebuilding every time the port
changes, I'd just put it in the program's source code. If it needs to
change independently of the program, it goes in /etc/services.