服务器:
import java.io.*;
import java.net.*;
public class Server {
public static void main(String args[]) throws IOException {
ServerSocket ss=new ServerSocket(1001);
String say=null;
PrintWriter pw=null;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("服务器正在运行,端口号是"+ss.getLocalPort());
System.out.println("正在监听...");
while(true) {
Socket socket;
socket=ss.accept();
System.out.println("已经连接到客户端了");
      new startThread(socket).start();
      pw=new PrintWriter(socket.getOutputStream());
      while((say=br.readLine())!=null) {
      // System.out.println(say);
      pw.println(say);
      pw.flush();
      }
     
}
}}class startThread extends Thread {
public startThread(Socket socket) {
this.socket=socket;
}
public void run() {
try {
br=new BufferedReader(new InputStreamReader(socket.getInputStream()));

sin=new BufferedReader(new InputStreamReader(System.in));
while(flag) {
while((word=br.readLine())!=null) {
System.out.println("客户端说:"+word);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}
boolean flag=true;
BufferedReader br=null;
BufferedReader sin=null; String word;
String say;
Socket socket=null;
}一个客户进入可以进行通信,为什么再来一个,第二个就不能发消息呢???