if(server&&network){
try{
serverSocket = new ServerSocket(12345);
socket = serverSocket.accept();
System.out.println("Connected to " + socket.getInetAddress().getHostName());
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
out.writeObject(lou);
out.flush();
out.reset();
out.writeObject(dud);
out.flush();
out.reset();
me = new Gen(lou, dud);
//socket.close();
//serverSocket.close();
}catch(IOException ioException){
ioException.printStackTrace();
}
}else if(network&&!server){
try{
//Socket socket = new Socket("10.69.18.244", 12345);
socket = new Socket("192.168.1.100", 12345);
//Socket socket = new Socket("10.69.18.162", 12345);
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
lou = (ArrayList)in.readObject();
//in.reset();
dud = (ArrayList)in.readObject();
//in.reset();
me = new Gen(dud, lou);
//socket.close();
}catch(Exception ioException){
ioException.printStackTrace();
}
}
當我嘗試在服務器上使用out.writeobject(lou)
時,出現NullPointerException。客戶端拋出一個NotSerializableException
。我不知道爲什麼,因爲我正在初始化它。使用java中的套接字進行對象轉移
請正確使用術語。 「實時」在計算中具有特定的含義,這不是它。你的意思是「真實世界」嗎?或'及時'? – EJP 2013-02-08 20:37:04