Posted By:
Steven_Pearson
Posted On:
Thursday, January 1, 2004 07:27 AM
Hi,
The ObjectInputStream constructor tries to read header bytes from the underlying stream.
I suspect you have code like this
---8<---
//client
s = new Socket();
in = new ObjectInputStream( s.getInputStream() );
out = new ObjectOutputStream( s.getOutpuStream() );
---8<---
---8<---
//server
s = serverSocket.accept();
in = new ObjectInputStream( s.getInputStream() );
out = new ObjectOutputStream( s.getOutpuStream() );
---8<---
The ObjectInputStream constructors both try to read header bytes from the stream and BLOCKS.
As the read is blocked the ObjectInputStream will never complete construction.
An ObjectOutputStream must be attached to the opposite end of the socket before the ObjectOutputStream is constrected.
During construction the ObjectOutputStream writes the header tot he underlying stream ready for the ObjectInputStream at the opposite end to pick it up.