Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*; import java.net.*; public class ServidorTCP {
- public static void main(String[] args) { String lin, maylin; try{ int port =1234; ServerSocket welcome = new ServerSocket(port); while (true){ System.out.println("Esperando solicitudes en puerto "+port); Socket conecta = welcome.accept(); //espera que alguien quiera conectarse System.out.println("Conectado a "+conecta.getInetAddress()+":"+conecta.getPort()); BufferedReader entra = new BufferedReader( new InputStreamReader(conecta.getInputStream())); DataOutputStream sale = new DataOutputStream(conecta.getOutputStream()); lin = entra.readLine(); while (lin != null){ System.out.println("Recibido: "+lin); maylin = lin.toUpperCase()+"\n"; sale.writeBytes(maylin); lin = entra.readLine();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement