客户服务器编程 服务器 客户 int port=8000; int port=8000; DatalnputStream in; String host="localhost" DataOutputStream out; DatalnputStream in; ServerSocket server, DataOutputStream out: Socket socket: Socket socket; 连接请求 server =new ServerSocket(port); socket=server.accept(); socket=new Socket(host,port); in=new DatalnputStream in=new DatalnputStream (socket.getInputStream()); (socket.getInputStream()); out=new DataOutStream I/O out=new DataOutputStream (socket.getOutputStream()): 数据流 (socket.getOutputStream()); System.out.println(in.readDouble()); out.writeDouble(aNumber); out.writeDouble(aNumber); System.out.println(in.readDouble(); ©2006计算机系杨群 All rights lefts reserved.©2006 计算机系 杨厚群 All rights & lefts reserved. 客户/服务器编程 int port = 8000; DataInputStream in; DataOutputStream out; ServerSocket server; Socket socket; server =new ServerSocket(port); socket=server.accept(); in=new DataInputStream (socket.getInputStream()); out=new DataOutStream (socket.getOutputStream()); System.out.println(in.readDouble()); out.writeDouble(aNumber); int port = 8000; String host="localhost" DataInputStream in; DataOutputStream out; Socket socket; socket=new Socket(host, port); in=new DataInputStream (socket.getInputStream()); out=new DataOutputStream (socket.getOutputStream()); out.writeDouble(aNumber); System.out.println(in.readDouble()); 服务器 客户 连接请求 I/O 数据流