Java - Sockets

 
Vista:

Sockets

Publicado por carlos (1 intervención) el 09/11/2011 18:56:34
hola a todos en internet estuve navegando y encontre este ejercicio en java lo que trata con sockets pero ahora me dio la curiosidad k con la direc ip enviamos mensajes la tarea es k el servidor pueda recepcionar el envio de 3 maquina.

tendria que usar hilos ?

SERVIDOR

public static void main(String[] args) throws IOException {
// TODO code application logic here
ServerSocket servidor_UTEA=new ServerSocket(5000);
System.out.println("Servidor Iniciando");
Socket cliente=servidor_UTEA.accept();
DataInputStream leer=new DataInputStream(cliente.getInputStream());
System.out.println("El mensaje recibido fue : " + leer.readUTF());
cliente.close();


}

CLIENTE

public static void main(String[] args) throws IOException {
// TODO code application logic here
Socket cliente=new Socket("10.0.1.82",5000);
System.out.println("Cliente Iniciado");
DataOutputStream envio=new DataOutputStream(cliente.getOutputStream());
envio.writeUTF("hola amigos del Foro el Hacker.net:");

}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder