Solved

Finding User's IP Address.

Posted on 1998-07-29
3
178 Views
Last Modified: 2010-03-30
I'm looking for a complete program (in .class type) that will do the following thing :

Let's say I have a chat, which consists of 10 users at the present. I want to find the IP address of one of the users (not the chat IP, the user IP).

I'm giving a lot of points, because I need it bbbaaaddd.
0
Comment
Question by:yyyannag
3 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1229017
The function you are looking for, is it internal or external to the chat program. That is are you going to write a chat program in Java and looking for a particular module implementation or you have an existing chat program and want an independent application which determines user's IP addresses?
0
 
LVL 1

Accepted Solution

by:
mbelonga earned 450 total points
ID: 1229018
Depending on your implementation and chat server protocol, the *exact* way you'd go about getting the user's ip address will vary, but in general the answer is relatively simple:

Assuming you're writing a chat server, you will have a java.net.ServerSocket doing a
  server.accept();
somewhere.

accept() returns a java.net.Socket connection to the remote host.

All you would have to do to get the ip address of that remove host is something like this:
  Socket client = server.accept();
  String clientIp = client.getInetAddress().getHostAddress();

And then if you stored these clientIp Strings somewhere with mappings to usernames (such as a Hashtable), you would easily be able to retrieve the ip adress of any particular username.
0
 
LVL 2

Author Comment

by:yyyannag
ID: 1229019
I'm sorry, But I asked for a full program in Java, Since I don't have the slightest idea in Java programming. I'm increasing the points as a good will gesture, And hope I will get my answer soon.

P.S. If you need the address of the chat, it's :

http://chat.iol.co.il/chat/javachat.htm

I want to find the IP number of any user I choose, not the IP number of the srever the chat is working from.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 104
What's wrong with this code? 4 34
junit as external jar or library 7 36
Coding for the first time 9 62
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question