Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: Picking an unused port number Date: Wed, 8 Jun 2016 10:32:35 +0100 Lines: 16 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net +21fExd9NoYxrMi9PWClDw1A4r5f9FmukxAe+HoUaVbbG8lOGb Cancel-Lock: sha1:H5D6aPBxyPKvX5LpsGeSwUV6rWc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:34562 One more point. The rmiregistry is not necessarily an external application which you have to run separately. You can make your server application its own rmiregistry, or use an external registry is one is available. All that's required for RMI to work is that the client knows what port the rmiregistry (with which the RMI server has registered) is listening on. After that the rest is up to you. You can make your server an RMI server, or just use an RMI wrapper to deliver the assigned port number to the client, which can then use that port number to connect to a traditional Socket server. Once RMI is being used you can add as many services to it as you deem necessary. My main usage for RMI is delivering real-time radar data to the internet. Each data channel from each radar has a separate RMI server, each of which register with the rmiregistry. When a client wants data from a particular radar it queries rmiregistry to get a Remote interface to the RMI server. This interface includes the methods for requesting data from the RMI server. Personally, I don't trust rmiregistry over the Internet, so rmiregistry is blocked by the firewall for anything other than local networks. For remote access I use a GenericServlet inside Tomcat which accepts requests, uses rmiregistry to locate the relevant radar data server, reads the requested data and returns the result as a serialized Java object.