I am trying to implement a Thread which pings LAN connections continously. I would like to do that by creating new Socket
for each IP, while handling exceptions if it fails to connect. However, the execution of the sequence time outs at creating the socket (i signed it with a comment in the code).
How could i solve this Problem?
class Ping implements Runnable
{
private int actPort = 1024;
public void run()
{
Socket s;
int[] ip = {192,168,0,0};
while(true){
try {
for(int i = 0;i<256;i++)
{
ip[2] = i;
for(int j = 0;j<256;j++)
{
ip[3] = j;
String address = ip[0]+"."+ip[1]+"."+ip[2]+"."+ip[3];
s = new Socket(address,actPort); // EXECUTION STOPS
System.out.println(address);
}
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
}
Thanks for your time