ServerPort protocol option [PORT]

Specifies the port the database server is running on.

Usage

TCP/IP, HTTP, HTTPS

Values

Integer

Default

The default value for TCP/IP is 2638. The default value for HTTP is 80. The default value for HTTPS is 443.

Remarks

The Internet Assigned Numbers Authority has assigned the SQL Anywhere database server port number 2638 to use for TCP/IP communications. However, other applications are not disallowed from using this reserved port, and this may result in an addressing collision between the database server and another application.

In the case of the database server, the ServerPort protocol option designates the port number on which to communicate using TCP/IP. You can specify a single port number, or a combination of individual port numbers and ranges of port numbers. For example:

When you specify a list and/or range of port numbers, the database server attempts to bind to all specified port numbers.

The database server always listens on UDP port 2638 on most operating systems, even if you specify a different port using a network protocol option. Applications can connect to the database server without specifying a port number. Having this port available allows SQL Anywhere clients to find SQL Anywhere database servers running on other subnets and through firewalls.

For a client, the ServerPort protocol option informs the client of the port or ports on which database servers are listening for TCP/IP communication. The client broadcasts to every port that is specified by the ServerPort (PORT) protocol option to find the server.

If you using a web server, by default, the database server listens on the standard HTTP and HTTPS ports of 80 and 443, respectively.

If you start a database server using TCP/IP port number 2638 (the default), then the server also listens to UDP port 2638. The database server listens to UDP ports and responds to requests on these ports so that clients can locate the database server by server name.

If the database server's TCP/IP port number is not 2638, then the server listens to the same UDP port as the TCP/IP port.

UDP packets sent by the database server in response to client broadcasts contain no sensitive information. The data contained in these packets is limited to:

You can hide database names from broadcast requests by using the -dh option. You can also specify -sb 0 to disable the UDP listeners completely.

Differences on Mac OS X

Mac OS X does not allow multiple processes to bind to the same UDP port. When the database server is running on one of these platforms, it only listens to the specified UDP port or port 2638 if no port is specified.

This means that clients must specify the TCP/IP port number if the server is not using the default port (2638).

For example if the database server is started with the command dbsrv11 -n MyServer samples-dir/demo.db, a client on the same subnet can find the server using the following connection parameters ENG=MyServer;LINKS=tcpip. If another server is started on Mac OS X, with the following command dbsrv11 -n SecondServer -x tcpip(PORT=7777) samples-dir/demo.db, a client on the same subnet can find the server using the connection parameters ENG=SecondServer;LINKS=tcpip(PORT=7777). Note that if the database server was running on a platform other than Mac OS X, then the client would not need to specify the PORT parameter.

Additionally, on Mac OS X, if a SQL Anywhere database server is already using port 2638, and a second network database server was started without the PORT protocol option, the second network server would fail to start. The reason for this is users need to know and specify the server's port number in their connection parameters. Personal servers start successfully, even if port 2638 is in use, because shared memory is normally used to connect to personal servers.

See also
Example

The following example shows how to use the PORT protocol option to specify the port the server starts on.

  1. Start a network database server:

    dbsrv11 -x tcpip -n server1

    Port number 2638 is now taken.

  2. Attempt to start another database server:

    dbsrv11 -x tcpip -n server2

    The default port is currently allocated, and so the server starts on another port. On Mac OS X, this will fail.

  3. If another web server on your computer is already using port 80 or you do not have permission to start a server on this low of a port number, you may want to start a server that listens on an alternate port, such as 8080:

    dbsrv11 -xs http(port=8080) -n server3 web.db