[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

Reading data pushed to a TCP socket after it is closed

I have a C++ program ( which would be difficult to update) that  pushes a bunch of ascii data to the connected socket then calls exit(0) which also closes the socket.

I have been attempting to write a java client to the existing C++ server program.  When I reading the input from the socket using a stream using BufferedReader, I get a "java.net.SocketException: Connection reset" instead of being able to read to the end of the data already pushed to the socket. Does anyone know a way to get Java to let me read all of data?
1 Solution
I'm confused. You want to 'translate' the C++ client into Java?
QlemoC++ DeveloperCommented:
Closing the TCP socket before all packets are acknowledged is rogue. TCP is a reliable protocol, and needs its packet to be acknowledged. As soon as the socket is closed, a FIN or RST is sent, and the connection has gone. There is no way to access the closed socket anymore for the application. There are, however, ways to monitor traffic, as packet capturing software (WireShark) does.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now