1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import java.io.*; import java.net.*; public class PuertoAbierto { public static void main(String[] args) { int puerto=2050; try { Socket clientSocket = new Socket("192.168.1.37",puerto); PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true); System.out.println("Puerto " + puerto + " abierto"); out.close(); clientSocket.close(); } catch (UnknownHostException e){ System.out.println(e); } catch (IOException e) { System.out.println("Puerto " + puerto + " cerrado"); } } } |