1 import java.net.*;
 2 import java.io.*;
 3 
 4 public class Main {
 5    public static void main(String[] args) {
 6       Socket Skt;
 7       String host = "localhost";
 8       if (args.length gt; 0) {
 9          host = args[0];
10       }
11       for (int i = 0; i < 1024; i++) {
12          try {
13             System.out.println("Looking for "+ i);
14             Skt = new Socket(host, i);
15             System.out.println("There is a server on port "
16             + i + " of " + host);
17          }
18          catch (UnknownHostException e) {
19             System.out.println("Exception occured"+ e);
20             break;
21          }
22          catch (IOException e) {
23          }
24       }
25    }
26 }

 

相关文章:

  • 2021-08-28
  • 2021-12-06
  • 2022-01-20
  • 2021-10-16
  • 2022-12-23
  • 2022-02-19
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2021-08-15
  • 2021-12-06
  • 2021-09-04
  • 2022-01-19
  • 2021-12-21
相关资源
相似解决方案