Frequently Asked Questions

What ports does an Ice application open?

Ice opens one port per 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. Under Windows, the run time opens an additional pair of ports per thread pool on the loopback interface. These ports are used by the run time to interrupt select during shutdown. (Under UNIX, the run time uses a pipe instead of a socket pair.)

If you want to know which ports are in use on your machine, you can use the netstat utility. The -ab option shows you which process is using what ports. For example, under Windows, if you are running the hello demo in 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

You will also notice two additional entries:

TCP october:3503 localhost:3504 ESTABLISHED 3072 [server.exe]
TCP october:3504 localhost:3503 ESTABLISHED 3072 [server.exe]

These are the two ports that are used by the Ice run time internally to interrupt select().

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]

In addition, you will find that the client also uses a pair of sockets internally:

TCP october:3507 localhost:3508 ESTABLISHED 1656 [client.exe]
TCP october:3508 localhost:3507 ESTABLISHED 1656 [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. (See the Ice manual for details on ACM).

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 Socket FAQ.)

Copyright © 2008 ZeroC, Inc.