I'm attempting to connect two separate applications via a TCP/IP socket. In this case neither of the applications is running as a "client" of the other, it would be easier to describe them as two separate servers who need to communicate with each other.
To receive the data I'm using the InputStream.Read()
function and once it receives a value of -1
it should stop processing. However, now the problem is that if another set of data comes along the InputStream
is already at the End of Stream (EOS
) and so all new data being sent is discarded or ignored. The only way I have found to fix this problem is that once the End of Stream has been reached I close the socket and reopen it which I think might be handled better some other way.
How can I reset the InputStream so that it is ready for the next set of data that may come along?