日期:2014-05-20  浏览次数:20809 次

输入输出流的问题
用SOCKET通讯,客户端发送的数据传到服务器,但服务器接收的数据没有更新(第一次成功的把数据发送过去并处理了,但以后每次“发送”,服务器显示的都是第一次的数据。)
应该是输入输出流的问题。但不知道应该怎么修改,请教高手指点!  
public   class   ServerTcp   extends   Thread   {
                public   ServerTcp()   {
                  this.start();
        }
      public   void   run(){
              new   Conn(client,id,sf);
            }
        }

class   Conn   extends   Thread{
public   Conn(Socket   client_socket,int   id,ServerFrame   sf){
                client   =   client_socket;
                this.id   =   id;
                this.sf   =   sf;
                try{
                        in   =   new   BufferedReader(new   InputStreamReader(client.getInputStream()));
                        client.getInputStream().read(receive_data);//把客户端传过来的数据读到一个字节数组里面

                        out   =   new   PrintStream(client.getOutputStream());
                        out.println( "Welcome...... ");
                        out.flush();

                }catch(IOException   ioe){
                        try{
                                client.close();
                        }catch(IOException   ioe2){
                                System.out.print( "Close   client   error ");
                                return;
                        }
                }
                this.start();
        }
  public   void   run(){
                try{
                        for(;;){
                            String   s   =   in.readLine();
                            if(s   ==   null){
                                    sf.ChatArea.append( "终端 "+id+ "退出\n ");
                                    return;