• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Applets, LocalHost and Proxies

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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.
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...?
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.

get schwifty. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!