当我用AWT和SWING编辑界面时,聊天程序是成功的,但当我用eclipse自带的SWT编辑界面,却发生了一个奇怪有趣的问题,当在server.class类中的
try {
ServerSocket ss = new ServerSocket(911);
Socket s2 = ss.accept();InputStream is = s2.getInputStream();
dis = new DataInputStream(is); // 准备输入流
OutputStream os = s2.getOutputStream();
dos = new DataOutputStream(os); // 准备输出流
} catch (IOException e) {
System.out.println("连接服务器出现故障!");
}
当程序运行到Socket s2 = ss.accept();时竟然运行不下去了,也没有抛出任何异常,不知道是什么原因,但是在用AWT和SWING编辑界面时是可以运行下去的,不知道是什么原因?
下面的地址是源程序
http://www.eclipseworld.org/bbs/job.php?action=download&pid=tpc&tid=5344&aid=1523
try {
ServerSocket ss = new ServerSocket(911);
Socket s2 = ss.accept();InputStream is = s2.getInputStream();
dis = new DataInputStream(is); // 准备输入流
OutputStream os = s2.getOutputStream();
dos = new DataOutputStream(os); // 准备输出流
} catch (IOException e) {
System.out.println("连接服务器出现故障!");
}
当程序运行到Socket s2 = ss.accept();时竟然运行不下去了,也没有抛出任何异常,不知道是什么原因,但是在用AWT和SWING编辑界面时是可以运行下去的,不知道是什么原因?
下面的地址是源程序
http://www.eclipseworld.org/bbs/job.php?action=download&pid=tpc&tid=5344&aid=1523
当程序运行到accept时被阻塞了
直到接收到连接请求是才会继续执行下面的程序.