Escolar Documentos
Profissional Documentos
Cultura Documentos
Programação e
desenvolvimento de
aplicações com TCP
*Servidor:*
import java.io.*;
import java.net.*;
*Cliente:*
import java.io.*;
import java.net.*;
public class ChatClient {
public static void main(String[] args) throws IOException {
Socket socket = new Socket("localhost", 8080);
PrintWriter out = new PrintWriter(socket.getOutputStream(),
true);
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
String userInput;
while ((userInput = input.readLine()) != null) {
out.println(userInput);
}
}
}