• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • 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?
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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