Take the 2-minute tour ×

I have an applet that connects back to a service running on the same host. The webserver that hosts the applet listens on both IPv4 and IPv6 as does the service that the applet wants to connect to.

The problem is that from the with in the applet all I can get is the page URL or the Codebase URL. From the the URL I can't detect if it was resolved to a IPv4 or IPv6 by the browser so when the applet was loaded via IPv6 and I use the URL to tell the applet which server to look for the service on it fails the Sandbox rules as it defaults to resolving to the IPv4 address.

The only solution that comes to mind is to sign the applet so it can request to connect to arbitrary servers, but I was hoping for a simpler solution (that doesn't involve buying certs or adding my custom CA to the truststore on all systems accessing the site).

Anybody got a better solution.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use InetAddress.getAllByName(). The order of the results will tell you which you should use (namely, you should try to use result[0] first).

The important question is not "how was the applet loaded", but "how should I connect to the host".

share|improve this answer

Your Answer


