日期:2014-05-20 浏览次数:20795 次
while (true) {
int port = Integer.parseInt(textField.getText());
try {
ServerSocket serverSocket = new ServerSocket(port);
Socket sk = serverSocket.accept();
BufferedReader bReader = new BufferedReader(
new InputStreamReader(sk.getInputStream()));
textArea.setText(bReader.readLine());
serverSocket.close();
bReader.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
package conn;
import java.io.*;
import java.net.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/*对象反串行化,与客户端定义一样*/
class Customer extends Object implements java.io.Serializable //封装登录信息
{
String custName; //用户名
String custPassword; //密码
}
class ChaXun extends Object implements java.io.Serializable //封装查询信息
{
String neirong; // 用户ID或用户姓名
}
class Exit extends Object implements java.io.Serializable //封装退出信息