package jelouda; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Scanner; public class Servidor { public static int PUERTO = 5000;//Indicamos el puerto del servidor public void ejecutar() { try { System.out.println("Lanzando Servidor..."); ServerSocket serverSocket = new ServerSocket(Servidor.PUERTO); Socket socket = serverSocket.accept(); BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));//Buffer entrada PrintWriter pw = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));//Buffer salida String cadenaRecibida = br.readLine(); pw.print(cadenaRecibida); pw.flush(); System.out.println("Fin del Servidor"); }catch(IOException e){ e.printStackTrace(); } } public static void main(String[] args) { Servidor server = new Servidor(); server.ejecutar(); } }