Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java socket problems half closing

Tags:

java

sockets

I'm using JDK 1.3 (BD-J platform) using tcp sockets.

I seem to be getting some errors half closing on the client end. If I'm done writing and close the lower socket output stream, I seem to get an exception trying to read from the server end (most messages go through if it's not closed), but when it's closed I run into troubles.

Attempting to debug with the server, shouldn't I be able to read everything the client sends even if the socket is closed? Just using the low socket Input stream on the server side. If I run it normally I get most message, attempt to run the server in the debugger I get 1 message then a Socket Exception Connection Reset.

Here is partial code on the client end of how it sends messages then closes when it's done writing, waits for all input to finish then closes the socket entirely.

http://pastie.org/private/cwc5uijl1x2ndwjwsun4lg

Really frustrated that I can't find the problem

like image 1000
dekz Avatar asked Feb 27 '23 08:02

dekz


1 Answers

You need Socket.shutdownOutput. Closing either the InputStream or the OutputStream of a Socket closes the Socket (crazy, but true).

like image 123
Tom Hawtin - tackline Avatar answered Mar 04 '23 06:03

Tom Hawtin - tackline