Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. IOException
  2.  
  3. IOException
  4.  
  5. try {
  6. Socket socket = new Socket(Lector.IP_DISPLAY, Lector.PUERTO_DISPLAY);
  7.  
  8. if (socket == null) {
  9. envio(cadena);
  10. return;
  11. }
  12. socket.setSoTimeout(2000);
  13. PrintStream out = new PrintStream(socket.getOutputStream());
  14.  
  15. out.println(cadena);
  16.  
  17. if (out != null) {
  18. out.close();
  19. }
  20.  
  21. if (socket != null) {
  22. socket.close();
  23. }
  24.  
  25. out = null;
  26. socket = null;
  27.  
  28. } catch (ConnectException cx) {
  29. // Aquí tratas la excepción, por ejemplo volver a intentar conectar.
  30. } catch (IOException ex) {
  31. LOGGER.log(Level.SEVERE, null, ex);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement