Advertisement
kaitoso

relojes cliente

Oct 7th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package relojes;
  2.  
  3. import java.io.*;
  4. import java.io.DataOutputStream;
  5. import java.io.InputStreamReader;
  6. import java.io.PrintStream;
  7. import java.net.ServerSocket;
  8. import java.net.Socket;
  9. import java.util.Calendar;
  10.  
  11. public class conector {
  12. Socket cliente,socket;
  13. ServerSocket server;
  14. int puerto = 9000;
  15.  
  16. String ip="192.168.0.182";
  17.  
  18. DataInputStream entrada;
  19. DataOutputStream salida;
  20. Calendar cale= Calendar.getInstance();
  21.  
  22. public void inicio(){
  23.  
  24.  
  25.  
  26. try{
  27.  
  28. cliente= new Socket(ip,puerto);
  29. //server=new ServerSocket(puerto2);
  30. // socket = new Socket();
  31. //socket= server.accept();
  32.  
  33. salida=new DataOutputStream(cliente.getOutputStream());
  34.  
  35. entrada= new DataInputStream(cliente.getInputStream());
  36. int hr=cale.get(cale.HOUR_OF_DAY)-1;
  37. String hora=hr+":"+cale.get(cale.MINUTE)+":"+cale.get(cale.SECOND);
  38. System.out.println("la hora actual del sistema es:"+hora);
  39.  
  40. salida.writeUTF(hora);
  41. //System.out.println(arre1[i]);
  42.  
  43.  
  44.  
  45.  
  46.  
  47. String msg= entrada.readUTF();
  48.  
  49.  
  50. System.out.println("la hora que me envio el servidor es: "+msg);
  51. Runtime r=Runtime.getRuntime();
  52.  
  53. Process pro1=r.exec("cmd /c time "+msg);
  54.  
  55.  
  56.  
  57. entrada.close();
  58. salida.close();
  59. cliente.close();
  60. }catch(Exception e){}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement