This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Matt Morrow wrote:
I have a simple client/server application that I've run for years and years on different platforms (Redhat, Fedora, Windows 7, XP, etc.) and under different version-levels of
Java. The client and server threads (in this case, reminder-messages being displayed at the appropriate time) communicate via a port and socket.
The socket connection uses one of the available ports on that desktop machine.
(And that port number can be assigned to an environment variable or to an init file)
socket = new Socket(address, int-port-number);
And also, the address is not assigned or used.
It's just a new String().
I'm dragged kicking and screaming into the new age we all live in, and thrust into virtual desktops.
One is Windows and one is Linux, but neither can use a socket/port like this anymore.
Do I now need to use a COM-port-redirector/Virtual-serial-port like socat Project?
First of all, there is no such a thing as a socket where "the address is not assigned or used". A socket communicates to a network address and port. A socket where the address is not used is like the post office trying to deliver mail without using the address.
Anyway, how does it work then? I am thinking that your previous systems were configured to use the loopback when the address is not specified. This is not the same as the address is not used -- what is happening is that the application specified null (or no address), and the naming server replaced it with an address. And in general, a loopback address is return in many cases.
So, what does this mean? Well, it could mean that the virtual systems are not configured to do that. It could also mean that that the systems are not configured with a loopback interface. For the first case, you can get around this issue by simply specifying the loopback address, instead of a blank string. For the second, you will need to talk to your system administrator to add the loopback interface.