Topic: 客户服务对话,代码没有语言错误,逻辑方面有错误! |
Print this page |
1.客户服务对话,代码没有语言错误,逻辑方面有错误! | Copy to clipboard |
Posted by: oath911 Posted on: 2005-05-27 00:24 代码没有语言错误 逻辑方面哪里应该有错误,请哪位大侠指教!!! 客户端: import java.io.*; import java.net.*; class client { public static void main(String[] args) throws IOException { Socket qq = null; DataInputStream in = null; DataInputStream sysin = null; DataOutputStream out = null; String s = " Welcome..."; String ins = null; try { qq = new Socket("127.0.0.1",4001); in = new DataInputStream(qq.getInputStream()); out = new DataOutputStream(qq.getOutputStream()); sysin = new DataInputStream(System.in); System.out.println; while(!s.equals("quit")) { s = sysin.readLine(); out.writeBytes; if((ins=in.readLine())!=null) { System.out.println("server: "+ins); } } } catch(UnknownHostException e){} finally { in.close(); out.close(); sysin.close(); qq.close(); System.exit(0); } } } 服务器: import java.io.*; import java.net.*; class server { public static void main(String[] args) throws IOException { ServerSocket ser = null; Socket qq = null; DataInputStream in = null; DataInputStream sysin = null; DataOutputStream out = null; String s =" Connect..."; String ins = null; try { ser = new ServerSocket(4001); qq = ser.accept(); in = new DataInputStream(qq.getInputStream()); out = new DataOutputStream(qq.getOutputStream()); sysin = new DataInputStream(System.in); System.out.println; while(!s.equals("quit")) { s = sysin.readLine(); out.writeBytes; //??????? if((ins=in.readLine())!=null) { System.out.println("client: "+ins); } } } catch(UnknownHostException e){} finally { in.close(); out.close(); sysin.close(); qq.close(); ser.close(); System.exit(0); } } } 请教!!!!!!!!!!!!!!!!!!!!!!!!! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |