Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.Socket;
- import java.net.UnknownHostException;
- /**
- * Created by Facu on 20/4/2017.
- */
- public class Main {
- public static void main(String[] args) {
- try {
- //186.133.247.89
- Socket socket = new Socket("186.133.247.89", 1243);
- DataInputStream entrada =new DataInputStream(socket.getInputStream());
- DataOutputStream salida = new DataOutputStream(socket.getOutputStream());
- salida.writeUTF("hola xd");
- salida.flush();
- String linea;
- while ((linea = entrada.readUTF()) != null)
- System.out.println(linea);
- entrada.close();
- salida.close();
- socket.close();
- } catch (UnknownHostException e) {
- System.out.println("Problemas de red");
- } catch (IOException e) {
- System.out.println(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement