日期:2014-05-20 浏览次数:20810 次
//类一: try { ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); reception = ois.readObject(); ois.close(); socket.close(); //关闭Socket } catch (Exception e) { e.printStackTrace(); } //类二: public Object reqInfo (Object req , Socket socket){ ArrayList al = (ArrayList) req; al.add(socket); Object obj = (Object) al; return obj; } //类三: public void jud_do(Object temp){ al = (ArrayList)temp; sokect = al.get(X).toString();//X代表类二中socket存的位置 receiveRequest(socket) } //类四: public void receiveRequest(Socket socket) { this.socket = socket; try { ObjectOutputStream oos= new ObjectOutputStream(socket.getOutputStream()); oos.writeObject(reception); oos.flush(); oos.close(); socket.close(); //关闭Socket } catch (Exception e) { e.printStackTrace(); } }