I have a server-client application and using java Sockets API.
The server will send bytes to the client by calling DataOutputStream's write(bytes[] b)
, the DataOutputStream is wrapped around client.getOutputStream
directly(no Buffer here).
This is a file download functionality And I'm going to support resume, I didn't use any HTTP here, I've implemented my own simple protocol.
I've seen these questions on SO :
1-question1.
2-C# question.
3-FileChannel question.
The first doesn't answer my question, I can't wrap DataOutputStream around ByteArrayOutputStream because the latter can't be wrapped around client.getOutputStream
and I don't know how to implement my own write(int i)
method(And don't want to use JNI).
the second is C# not java(and it's calling WIN API anyway, I'm a linux user by the way :) ).
The third is talking about FileChannels and HTTP, As I said I'm not using HTTP and I'm using java Socket's API.
So how to get how many bytes were actually written ?
PS (EDIT)
By resume support I mean I'll give the client the ability to stop download at specific byte and then after a while(minutes,hours,days,whatever) he/she can resume download from where it has left.