Hi!
I have made a client and a server which are supposed to communicate by
sending java objects. They don't.
I have managed to send an object from the client to the server. But
continuing after that I can't do the opposite. I want the program to send an
object-reply from the server to the client. But on this step boths sides
throw a socket exception.
From println's I have figured out that it can't set up on either side the
corresponding stream: output stream for the server and input stream for the
client.
I have closed the input stream on the server and the output stream on the
client from the first sending of the object.
The object that's being sent does implement serializable.
The blocks of code of setting up the streams are below.
Any help would be greatly appreciated.
Maria
Here is the code the client is running to receive (it throws the exception
just after the println statement):
System.out.println("in receive");
InputStream in = client.getInputStream();
ObjectInputStream receive = new ObjectInputStream(in);
Object received = receive.readObject();
receive.close();
in.close();
Here is the code the server is running to send (it throws the exception just
after the println statement):
System.out.println("in send");
OutputStream out = connection.getOutputStream();
System.out.println("got stream one");
ObjectOutputStream sendStream = new ObjectOutputStream(out);
sendStream.writeObject(toSend);
sendStream.close();
out.close();