private ServerSocket server = null;
private Socket socket=null;
private ObjectInputStream ois=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_server);
Button button = (Button) findViewById(R.id.two);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//strat();
tv.setText("按下开始\n");
try {
tv.setText("按下开始\n连接开始");
server = new ServerSocket(4444);
tv.setText("按下开始\n服务器启动成功");
socket = server.accept();
tv.setText("按下开始\n服务器启动成功\n连接成功");
ois = new ObjectInputStream(socket.getInputStream());
control c = (control) ois.readObject();
tv.setText("按下开始\n服务器启动成功\n连接成功\n" + c.getSssss());
} catch (Exception e) {
// 显示错误
tv2.setText("\n\n\n\n\n" + e.toString());
}
}
});
}