0

I write a client-socket program and make chat between different devices

but if i wanted to connect two device on network I Establised through CMD,

so if I Create Socket and bind to it such IP and Port

Socket clientSocket = new Socket("127.0.0.1", 6000);

i should replace the IP ( 127.0.0.1 ) to the IP of the anther machine in the network

Is there's a way to list all IPS in the network to select from it to put the IP automatically in the Sokect ?

1 Answers1

-1

You can use the approach mentioned in this post:

How to get a list of all valid IP addresses in a local network?

You can call these methods from your program using

Runtime.getRuntime().exec(command);

Hope this helps.

clinomaniac
  • 2,200
  • 2
  • 17
  • 22