Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created June 6, 2017 00:46
Show Gist options
  • Save joffilyfe/76c819b7b9509523e626ed53bc16d2b5 to your computer and use it in GitHub Desktop.
Save joffilyfe/76c819b7b9509523e626ed53bc16d2b5 to your computer and use it in GitHub Desktop.
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class ForcaCliente {
public static void main(String[] args) throws UnknownHostException, IOException {
Socket socket = new Socket("localhost", 7171);
DataInputStream in = new DataInputStream(socket.getInputStream());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
while (socket.isConnected()) {
System.out.println("Digite uma palavra: ");
Scanner teclado = new Scanner(System.in);
out.writeUTF(teclado.nextLine());
System.out.println("Resposta: " + in.readUTF());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment