Created
June 6, 2017 00:46
-
-
Save joffilyfe/76c819b7b9509523e626ed53bc16d2b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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