Hi, I am having a problem at receiving some data via a network.
I use the DataInputStream to read the data from a Socket. I always used to ask first for the number of bytes to receive, then create a byte array and store the data on there. The problem is that I need to read the data without asking the number of bytes. I tried reading until getting the -1 from the read method that means the end of the transmition, but the -1 is never read until the client closes the stream. That would be easy to solve just asking the client to close the stream, but the problem is that the client WONT close any stream because is not programmed on java but on another language that doesnt allow to close the streams.
What I am doing now is this:
1.- creating a byte array of 197 slots.
2.- read on it until the number of bytes read is different from the array length.
3.- store the parts on a file, if the number of bytes is different from the array length then add the new part to the file and finish.
this works but I am afraid that is the number of bytes to read is multiple of the array length then the server will blocked until getting new data. and thats a problem because I need to answer inmediatly with another things.