• Post Reply Bookmark Topic Watch Topic
  • New Topic

get client's IP adress without servlets or jsp?  RSS feed

 
Deborah Larsson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am working on a game where I amongst others have a GUI GamepickScreen, Gamechooser, Game and Player object.
Now the server based Gamechooser class handles the login of the user, and being able to choose a session from a list of games.
It sends that information to the client based GUI Gamepickscreen. During the login method a new Player instance is created with the name filled in on the screen.
That Player instance is thus on the server side as well and in it's constructor it stores the playername and IP address.
How can I fetch the public IP address of the client so that a server-based class can store it?
I found a few things when searching but most are about webbased javascript + JSP combinations. This is a regular networked application, not via http.

thanks
Deb
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the connection being established? If it involves a ServerSocket, then its accept() method returns a Socket object that can be used to obtain the client IP address.
 
Deborah Larsson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply.
I use RMI. I did not use ServerSocket before, but I looked it up and see that this is part of the RMI library.
This is what I used previously in a simpler application.


I am not sure at the moment if involving the serversocket is a better idea for this or in general.
Guess I'll read up on the topic.

Deb
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving thread as too difficult for "beginning."
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the static method "getClientHost()" in the class java.rmi.server.RemoteServer .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!