What ports does an Ice application open?

Ice opens one port per object adapter endpoint. The port is assigned according to your endpoint configuration. The Ice run time also opens a port for each outgoing connection; the port number for outgoing connections is chosen by the operating system.

If you want to know which ports are in use on your machine, you can use the netstat utility. The -ab option (Windows) or -ap option (UNIX) shows you which process is using what ports. For example, under Windows, if you are running the hello demo from the Ice distribution, you will see the following entries for the server, assuming no connections are established:

TCP october:10000 october:0 LISTENING 3072 [server.exe]
TCP october:10001 october:0 LISTENING 3072 [server.exe]
UDP october:10000 *:* 3072 [server.exe]

As you can see, the server listens on three ports, one each for TCP, SSL, and UDP. This is as expected because these ports are specified in the endpoint configuration of the demo:

Hello.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001

If you now run the client and re-run netstat, you will see two additional entries that represent the connection between the client and the server:

TCP october:10000 october.domain:3569 ESTABLISHED 4588 [server.exe]
TCP october:3569 october.domain:10000 ESTABLISHED 4872 [client.exe]

If you keep monitoring the netstat output and leave the client idle for a while, you will notice that the client connection to the server drops at some point. This is due to active connection management (ACM), which periodically closes idle connections.

You may also notice that some connections are in the TIME_WAIT state:

TCP october:4222 localhost:1780 TIME_WAIT 0
TCP october:4222 localhost:1812 TIME_WAIT 0

This is perfectly normal and part of the regular TCP/IP closing procedure. (For more detail on TIME_WAIT, have a look at the Unix Socket FAQ.)

See Also