Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applets, LocalHost and Proxies

 
Aliasgar Pocketwala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have developed a chat applet.
Everything worked until I tried to access it behind the firewall
after trying out a few things I was able to figure out that the SOCKS proxy of the firewall has to be opened up.
My question is this, although I know the Server Side port to connect to, the client side port is taken from the heap, I need to bind the socket with the port I supply in order to be able to configure the firewall to allow that particular internal port.
Now the only method in the Socket class which would do this seems to be Socket(InetAddress remoteHost, int remotePort, InetAddress localHost, int localPort);
Now this allows me to add the port but also needs the LocalHost. The best way to do this would be the InetAddress method getLocalHost(). However when I tried this in the Applet it gives me the default of 127.0.0.1 and the Socket refuses to connect giving me a NoRouteToHostException. What should I do?
Frankly speaking I have posted this on a number of forums without any luck. I hope anyone here can answer.
Thanks.
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InetAddress.getLocatHost() method just returns the address of local machine
but u want to get the address of the server to which u want a socket connection
try the ip address of the server address for which u want to connect.
feel free to ask if problem still exists...?
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aliasgar,
May be applet method :getCodeBase().getHost() useful for you.
Thanks
angela

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic