Hi, I would like to know how to connect several clients to the same socket server in Java. The problem is that when I connect a client using localhost or ip the next client that connects can not see the message you sent to the server
//clase cliente ya conectada al main de la aplicacion
package sockets3;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class cliente {
Scanner sc = new Scanner(System.in);
public void iniciar(){
ServerSocket server;
Socket socket;
int puerto = 9000;
DataOutputStream salida;
BufferedReader entrada;
try{
server = new ServerSocket(puerto);
socket = new Socket();
socket = server.accept();
String thisIp = InetAddress.getLocalHost().getHostAddress();
String com = "123";
while ( true){
System.out.println("*****Conectado*****");
System.out.println("IP:"+thisIp+"al puerto "+puerto);
entrada = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String mensaje = entrada.readLine();
}
}catch(IOException e){}
System.out.println("no hay cliente");
}
}