• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Applets, LocalHost and Proxies

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aliasgar,
May be applet method :getCodeBase().getHost() useful for you.
Thanks
angela

 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic