CANT receive data via a network, help me please
Hi, I am not as newbie as I look like to.
I am trying to receive data through a network. The problem is that I dont know the file size, so I kept reading until reaching the end of file and the save it to a file. The problema is that I am never geting the -1 result from the read method.
Now, I noticed that the -1 is returned when I close the DataOutputStream. So thats okay. The problem is that the sender is not make in java, but on pocketBuilder. And I cant ask for the client to close an outputStream. So Is there any way to just read the data without knowing the number of the bytes to receive and doesnt waiting for the end of the stream.
[664 byte] By [
MelGohana] at [2007-11-27 4:22:09]

# 2
Well, I could read the data without asking for the end of the file nor knowing the number of bytes. I read into byte arrays of a certaing number.
If the bytes read were as many as the array length. Then put them in a file if not, take only the new contento of the array and append it to the file. AT the end I have my data read.
# 4
When the number of bytes read is less than the array length, but now I notice that if by coincidence the end just fits exactly one array then the next iteration will have 0 bytes to read then it will keep waiting!!!!!! in fact now I notice that this only works if the number of bytes to read is not a multiple of the length of the array.
Any other wahy, maybe a timer (if is not receiving any byte for 20 seconds then cut the conexion?)
# 5
> When the number of bytes read is less than the array
> length
That doesn't necessarily mean you're at the end of the data.
> Any other wahy, maybe a timer (if is not receiving
> any byte for 20 seconds then cut the conexion?)
Again that doesn't necessarily mean you're at the end of the data.
There is no way to know you're at the end of the data without either an application protocol containing the length, or a socket close at the sender.
ejpa at 2007-7-12 9:29:24 >
