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.prin tln("in receive");
InputStream in = client.getInput Stream();
ObjectInputStre am receive = new ObjectInputStre am(in);
Object received = receive.readObj ect();
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.prin tln("in send");
OutputStream out = connection.getO utputStream();
System.out.prin tln("got stream one");
ObjectOutputStr eam sendStream = new ObjectOutputStr eam(out);
sendStream.writ eObject(toSend) ;
sendStream.clos e();
out.close();
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.prin tln("in receive");
InputStream in = client.getInput Stream();
ObjectInputStre am receive = new ObjectInputStre am(in);
Object received = receive.readObj ect();
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.prin tln("in send");
OutputStream out = connection.getO utputStream();
System.out.prin tln("got stream one");
ObjectOutputStr eam sendStream = new ObjectOutputStr eam(out);
sendStream.writ eObject(toSend) ;
sendStream.clos e();
out.close();
Comment