Why is this ObjectInputStream constructor blocking?
The ObjectInputStream constructor is blocking even though I have already instantiated the corresponding ObjectOutputStream and called flush() to write the header.
Anyone have any idea why?
socket =new Socket(ipAddr, port);
socket.setSoTimeout(TIMEOUT);// timeout after 1 minute
output =new ObjectOutputStream(socket.getOutputStream());
output.flush();
input =new ObjectInputStream(socket.getInputStream());
> Sorry, I forgot to say that the socket connection is> to localhost, so this thread is both sides.Errr. No it isn't. Even when you connect to localhost you have two sockets. All I see here is you using one of them.
To put it another way. Using localhost does not get you out of using two sockets (one at either end) or any other difference to your code at all.
The only difference in using localhost to a remote IP is that the performance will be rather significantly better. But it makes no diffference to your code in any way shape or form.