In client-server approach, how to get an IP address of remote machine, and how we can find whether tht machine is connectedwith server or not. I hv found one solution is pinging in background, but how we can do such pinging? how can we find out tht we r getting reply of ping?

Showing Answers 1 - 3 of 3 Answers

Supraja

  • Feb 20th, 2006
 

you can know this by some code, ex applet.

Try with this: getInetAddress() on your Socket instance then it will give Ip Address.

else this shd also work

InetAddress localHost = InetAddress.getLocalHost();
InetAddress[] all_IPs = InetAddress.getAllByName(localHost.getHostName());
for (int i=0; i<all_IPs.length; i++) {
        System.out.println("IP address = " + all_IPs[i]);
}

  Was this answer useful?  Yes

Parikshit Chuasma

  • Mar 26th, 2006
 

Well,

I think it will be better if a part of request, client itself passes its IP address information to the server. ( I know thereare several issues here ).

and secondly, If the client is able to send requests, then its connected. I don't think we should be writting the server application such that it keeps polling for every clients connected!

Correct me if I am wrong.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions