用GZIP流压缩数据,用socket来发送和接收,可时运行时,好像出现了死锁。
服务器端是监听到了客户端,但客户端却收不到任何数据。请问高手这是怎么回事啊?
代码如下:public class socketclient {
   public static void main(String argv[]) {
      ObjectOutputStream oos = null;
      ObjectInputStream ois = null;
      GZIPInputStream zin=null;
      GZIPOutputStream zos=null;
      Socket socket = null;
      Date date = null;
      try {
        // open a socket connection
        socket = new Socket("127.0.0.1", 3000);
        // open I/O streams for objects
        zin=new GZIPInputStream(socket.getInputStream());
        zos=new GZIPOutputStream(socket.getOutputStream());
        ois = new ObjectInputStream(zin);
        oos = new ObjectOutputStream(zos);
 //       oos = new ObjectOutputStream(socket.getOutputStream());
 //       ois = new ObjectInputStream(socket.getInputStream());        // read an object from the server
        date = (Date) ois.readObject();
        System.out.print("The date is: " + date);
        zos.finish();
        oos.close();
        ois.close();
      } catch(Exception e) {
        System.out.println(e.getMessage());
      }
   }
}public class socketserver extends Thread {
   private ServerSocket dateServer;
   public static void main(String argv[]) throws Exception {
     new socketserver();
   }
   public socketserver() throws Exception {
     dateServer = new ServerSocket(3000);
     System.out.println("Server listening on port 3000.");
     this.start();
   }
   public void run() {
     while(true) {
       try {
        System.out.println("Waiting for connections.");
        Socket client = dateServer.accept();
        System.out.println("Accepted a connection from: "+client.getInetAddress());
        Connect c = new Connect(client);
       } catch(Exception e) {}
     }
   }
}
class Connect extends Thread {
   private Socket client = null;
   private ObjectInputStream ois = null;
   private ObjectOutputStream oos = null;
   private GZIPInputStream zis=null;
   private GZIPOutputStream zos=null;
   public Connect() {}
   public Connect(Socket clientSocket) {
     client = clientSocket;
     try {
     zos=new GZIPOutputStream(client.getOutputStream());
     zis=new GZIPInputStream(client.getInputStream());
     ois = new ObjectInputStream(zis);
      oos = new ObjectOutputStream(zos);
 //      ois = new ObjectInputStream(client.getInputStream());
 //   oos = new ObjectOutputStream(client.getOutputStream());     } catch(Exception e1) {
         try {
            client.close();
         }catch(Exception e) {
           System.out.println(e.getMessage());
         }
         return;
     }
     this.start();
   }
   public void run() {
      try {
         oos.writeObject(new Date());
         oos.flush();
         zos.flush();
         // close streams and connections
         ois.close();
         oos.close();
         client.close();
      } catch(Exception e) {}
   }
}