oath911
发贴: 8
积分: 0
|
于 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); } }
}
请教!!!!!!!!!!!!!!!!!!!!!!!!!
oath911 edited on 2005-05-27 00:34
|