一个是客户端,一个是服务端,我在我的eclipse上调试怎么总提示错误呢?我是win7系统,小白先谢谢大家帮忙解围啦。
客户端:
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.*;
public class ChatClient extends Frame { TextField tfTxt = new TextField();
TextArea taContent = new TextArea(); public static void main(String[] args) {
new ChatClient().launchFrame();
} public void launchFrame() {
setLocation(400, 300);
this.setSize(300, 300);
add(tfTxt, BorderLayout.SOUTH);
add(taContent, BorderLayout.NORTH);
pack();
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
tfTxt.addActionListener(new TFListener());
setVisible(true);
connect();
}

public void connect(){
try {
Socket s = new Socket("localhost",1069);
System.out.print("connected!");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private class TFListener implements ActionListener{ public void actionPerformed(ActionEvent e) {
String s = tfTxt.getText().trim();
taContent.setText(s);
tfTxt.setText("");
}

}
}
下面这个是服务端:
import java.io.*;
import java.net.*;public class ChatServer { public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(1069);
while(true){
Socket s = ss.accept();
System.out.println("a client connected!");
}
} catch (IOException e) {
e.printStackTrace();
}
}}提示错误:
java.net.SocketException: select failed
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at ChatServer.main(ChatServer.java:10)
我的是eclipse Version: 3.7.2