1
2
3
4
5
6
7
8
9 import java.io.*;
10 import java.net.*;
11
12 public class Servidor{
13 public static final int puerto = 9999;
14
15 public static void main(String[] args) throws IOException{
16 ServerSocket socketEscucha;
17 Socket socket;
18 DataInputStream entrada;
19 String mensaje;
20
21 socketEscucha = new ServerSocket(puerto);
22 socket = socketEscucha.accept();
23 entrada = new DataInputStream(socket.getInputStream());
24 mensaje = entrada.readLine();
25 System.out.println(mensaje);
26 socket.close();
27 socketEscucha.close();
28 }
29 }
30
Java/Programas/SocketSencillo/Servidor.java (last edited 2008-04-20 14:39:39 by localhost)