我在更新我的序列化对象时遇到问题。客户端不刷新服务器发送的数据。我在客户端中创建了循环,但它仍然没有更新。
public void run(){
try {
socket = new Socket(host.getText(), new Integer(port.getText()));
wyswietlKomunikat("Connected.");
我在客户端中创建了循环,但它仍然没有更新。
// Serialization
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
while(true){
Pakiet p = (Pakiet) ois.readObject();
showHome(p.getHome());
ShowAway(p.getAway());
showHomeLine(p.getShowHomeLine());
showAwayLine(p.getShowHomeLine());
// end of serialization
in = new Scanner(socket.getInputStream());
while(in.hasNextLine()){
showComment(in.nextLine());
}
}
}
catch (UnknownHostException e) {
showComment("no connection!");
}
catch (IOException e) {
showComment(e.toString());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
try {
socket.close();
}
catch(IOException e) {
}
}