Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.io.*;
  2. import java.net.Socket;
  3. import java.net.UnknownHostException;
  4.  
  5. /**
  6. * Created by Facu on 20/4/2017.
  7. */
  8. public class Main {
  9. public static void main(String[] args) {
  10. try {
  11.  
  12. //186.133.247.89
  13. Socket socket = new Socket("186.133.247.89", 1243);
  14.  
  15. DataInputStream entrada =new DataInputStream(socket.getInputStream());
  16. DataOutputStream salida = new DataOutputStream(socket.getOutputStream());
  17.  
  18. salida.writeUTF("hola xd");
  19. salida.flush();
  20.  
  21. String linea;
  22.  
  23. while ((linea = entrada.readUTF()) != null)
  24. System.out.println(linea);
  25.  
  26. entrada.close();
  27. salida.close();
  28.  
  29.  
  30. socket.close();
  31. } catch (UnknownHostException e) {
  32. System.out.println("Problemas de red");
  33. } catch (IOException e) {
  34. System.out.println(e.getMessage());
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement