here is the server side code of my program, the problem is, its accepting one client. when another client is connected, the isConnected method returns true, but the server does not gets the messages from the server. please help me as this is my first java program in netbeans, i have just finished studying core java.
class Conn extends Thread{
ServerSocket ss;
Socket s;
public void run()
{
status.setText(status.getText()+"connecting");
try{
while(true)
{
s=new Socket();
ss=new ServerSocket(3000);
s=ss.accept();
Read r=new Read(s);
r.start();
}
}catch(Exception e){}
}
}
class Read extends Thread{
DataInputStream inp;
PrintStream outp;
String str;
Read(Socket s)
{
try{
inp=new DataInputStream(s.getInputStream());
outp=new PrintStream(s.getOutputStream());
}catch(Exception sd){}
}
public void run()
{
status.setText(status.getText()+"\nreading");
try{
while(true)
{
str=inp.readLine();
chatwin.append(str);
outp.println(str);
}
}catch(Exception er){}
}
}
readLine()for null. When you get null you must close the socket and exit the thread.