hi there,
i have this server code that send the received message from one client to all the other clients, including the one how send the message
public class Chat extends Thread{
static LinkedList<PrintStream> sll;
Socket cs;
PrintStream ps;
public Chat(Socket cs){
this.cs=cs;
try{
ps=new PrintStream(cs.getOutputStream());
sll.add(ps);
this.start();
}
catch (Exception ex){ex.printStackTrace();}
}
public void run(){
try{ DataInputStream dis=new DataInputStream(cs.getInputStream());
while (true){
String s=dis.readLine();
for(PrintStream bps:sll) bps.println(s);
}
}
catch (Exception ex){
ex.printStackTrace();
sll.remove(ps);}
}
public static void main(String[] args) throws Exception{
sll=new LinkedList<PrintStream>();
ServerSocket ss=new ServerSocket(9000);
while(true)
{
Socket s=ss.accept();
Chat cs=new Chat(s);
}
}
}
How to edit this code to make it send the received message to all clients except the one who send it??
thanks in advance