Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Raw socket connection using crossdomain support

843790Jun 6 2009 — edited Feb 8 2010
Good day,

Is there a way to force a Socket(hostname, port) connection to connect using the dns hostname rather than IP address. The hostname is passed to the Socket() call but when crossdomain Java converts and connects using the IP.

As the background to this I have an unsigned applet on websiteA that needs to make a HTTP POST request to websiteB using the JavaSE 6 update 10 crossdomain.xml support.

Using Java's URL() method this works fine however I need to do this via sockets, which always errors with:

access denied (java.net.SocketPermission 123.234.123.234:80 connect,resolve)

When using the socket approach on websiteA to websiteA communication this works fine and I note always shows as "network: Connecting http://websiteA.com:80/ with proxy=DIRECT" whereas when crossdomain from websiteA to websiteB Java starts using the IP address "network: Connecting http://123.234.123.234/crossdomain.xml with proxy=DIRECT"

When using the URL() approach for crossdomain from websiteA to websiteB (which works fine) Java still reports "network: Connecting http://websiteB.com:80/ with proxy=DIRECT" (i.e. using the hostname rather than IP), I'm therefore presuming the socket approach trying to use websiteB's IP rather than hostname is the issue.

I've setup websiteB to respond on both it's hostname and IP address, with a valid crossdomain.xml returned for both. Java reports "network: CrossDomainXML: connection to host 123.234.123.234 allowed" suggesting it should even be able to work on the IP address, however Exceptions as the above error.

Please note - the applet needs to remain unsigned.

Regards,
BP
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2010
Added on Jun 6 2009
22 comments
643 views