Programação de socket TCP- Client import java.io.*; import java.net.*; import java.util.Scanner; public class TCPclient { public static void main(String[] args) throws Exception { //lendo do teclado String inFromUser = new Scanner(System.in).next(); //criando um socket TCP Socket sock = new Socket( localhost , 2000); //stream de saida DataOutputStream socketOut = new DataOutputStream(sock.getOutputStream()); socketOut.writeBytes(inFromUser + \n ); //resposta do servidor BufferedReader socketIn = new BufferedReader(new InputStreamReader(sock.getInputStream())); System.out.println(socketIn.readLine()); }
{}