import java.io.*;
import java.net.*;
public class ChatServer {
public static void main(String []args) {
try {
ServerSocket ss = new ServerSocket(6888);
Socket so = ss.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(so.getInputStream()));
BufferedReader brs = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(so.getOutputStream()));
String s = br.readLine();
System.out.println("Client" + s);
String c = null;
while(s != "exit") {
System.out.println("Client : " + s);
c = brs.readLine();
bw.write(c);
bw.flush();
System.out.println("Server : " + c);
s = br.readLine();
}
System.out.println("Chat Over");
br.close();
brs.close();
bw.close();
}
catch(Exception e) {}
}
}
我的一个小程序,上面是server
import java.io.*;
import java.net.*;
public class ChatClient {
public static void main(String []args) {
这是client,其实就是一个简单的,白痴的对话器,但是我怎么调试也不对,编译通过了,但是运行的时候一直卡在那里,感觉是io出问题了,大师们劳烦看看呗。非常感谢,实在是自己看不出来了。。。。。
aluckdog
相关分类