Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IP socket connect.  RSS feed

 
Asaf Karass
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All!
I got this source code for finding IP addresses who has some port num opened.
as you can see the addresses are been generated using a for() function and I think this make it work
kinda slow.
please help me to make it fast,
Asaf.
for (int v=11; v < 255; v++)
{
for (int j=1; j < 255; j++)
{
for (int k=1; k < 255; k++)
{
for ( int l = 1; l<255; l++)
{
for (int m=1; m<255; m++)

{
String str = new String(v + "." + j + "." + k + "." + m);

JOptionPane.showMessageDialog(null , str, "Hey!", JOptionPane.ERROR_MESSAGE);


try{
Socket sk = new Socket(str,80);
}
catch(java.net.UnknownHostException jnue)
{
JOptionPane.showMessageDialog(null,"Address sh'll not exsist.", str, JOptionPane.ERROR_MESSAGE);
}

catch(java.io.IOException jiioe)
{
JOptionPane.showMessageDialog(null,"I/O Exception", str, JOptionPane.ERROR_MESSAGE);
}

catch(java.lang.SecurityException jlse)
{
JOptionPane.showMessageDialog(null,"Security exception.", str, JOptionPane.ERROR_MESSAGE);
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!