Archived

This forum has been archived. Please start a new discussion on GitHub.

Why Ice open several ports at 127.0.0.1?

Hi, all
I've found a strange behaviour of Ice. A typical Ice application will open several ports at 127.0.0.1 and use them to do in-process socket communication or something else. The problem is that why Ice need to do that and how to control the range of port? Because my application also needs some ports open at 127.0.0.1, I am afraid of port conflict if the behaviour of Ice is unpredictable.

Comments

  • benoit
    benoit Rennes, France
    There's nothing strange here :). Ice opens ports for each object adapter of your application (assuming you've configured endpoints for the object adapter).

    You can control the port number by using the -p option of an endpoint, for example: "tcp -p 12000 -h 127.0.0.1". If you don't specify the port number explicitly, the OS will assign a port which isn't already used -- you don't have to worry about Ice using ports which are already in use by your application. Please see the Ice manual for more information about how to configure object adapter endpoints.

    Benoit.
  • Thanks to benoit, but I am afraid you misunderstood my last post. I used a port-monitoring tool, such as aports to monitor every application in my computer. I've found that every Ice-based application open at least one port at 127.0.0.1 and connected to itself from another port to this port. For example, from 127.0.0.1:2280 to 127.0.0.1:2281. This connection is an in-process one and almost uncontrollable. So I worried about port conflict because some of my applications open ports at 127.0.0.1. And these ports cannot be changed as they are read from an ini file.
  • marc
    marc Florida
    This is under Windows, right? Under Windows Ice creates an internal connection for each thread pool. This is needed for technical reasons, so that the thread pool can interrupt itself. There can be no port conflict, because the port numbers are chosen dynamically.
  • I don't think there's no port conflict at all. Suppose an Ice-based application starts and chooses port 10000 at 127.0.0.1 to do internal thread-pool-related communication, what if later another application starts and wants to listen at 127.0.0.1:10000? This application can't divert to another port because 10000 is a supposed-to-be-exist port to its client-another application in the same host.
    Can Ice provide some mechanism to control its internal port usage?
  • marc
    marc Florida
    The automatically chosen ports are in a reserved range (1024-5000), so port 10000 could never be chosen. If this wouldn't work as it should, then you couldn't even run a Web browser on your system, because the port it might pick to connect to a Web server might conflict with other ports.
  • Thanks for your answer. Range 1024-5000 is too big, how can I change this range in Ice source code?
  • marc
    marc Florida
    You cannot, this range is given by the operating system.