I have a strange problem to send a serializable object that I have created over socket. In fact if I run the server and the client in the same machine it works well but if the server and the client are in different machines the readen object in the server side is empty (with size equal to zero)
Any one have an idea to fix that ? (the code is bellow)
Server:
public static void main () {
...
InputStream is = mysocket.getInputStream();
ObjectInputStream ois = new ObjectInputStream(is);
ArrayList<MyObject> list_of_object;
list_of_object = (ArrayList<MyObject>) ois.readObject();
logger.log(Level.INFO,"object readen with size : "+list_of_object.size());
...
}
Client:
public static void main () {
...
ObjectOutputStream oos = new ObjectOutputStream(mysocket.getOutputStream());
oos.writeObject(list_of_object);
...
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…