Android Question AsyncStreams counting byte

nicolino33

Active Member
Licensed User
Longtime User
Hello, is there a solution to count the transmitted bytes? (in socket output stream, not file or array)
 

nicolino33

Active Member
Licensed User
Longtime User
Hi Erel, thanks for your reply, I need it for look the amount of bytes transferts with progress bar!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are two options:

1. Send a CountingInputStream with AStream.WriteStream. This is good if you are sending a single large message (or file).
2. Check the queue size with OutputQueueSize. This is useful if you are sending many small messages. OutputQueueSize doesn't return bytes, it returns the number of messages waiting to be sent.
 
Upvote 0

nicolino33

Active Member
Licensed User
Longtime User
Thanks for your reply, but I can only use WRITE, I'm using visual basic to receive files, I tried to send them with WriteStream but it does not work, accept only WRITE mode, do you have an example of how to receive file with WriteStream in vb.net?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

nicolino33

Active Member
Licensed User
Longtime User
I'v made this, it work and send file, but the counter of countingStream is allways 0

Private asi As OutputStream
Public countingStream As CountingOutputStream
asi=Socket1.OutputStream
countingStream.Initialize(asi)
asi.WriteBytes(BufferFoto,0,BufferFoto.Length)
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

nicolino33

Active Member
Licensed User
Longtime User
Ok thanks, I'v solved:

Dim in As InputStream
Dim countingStream As CountingInputStream
Dim asi As AsyncStreams
asi.InitializePrefix(Socket1.InputStream,True,Socket1.OutputStream,"asi")
in.InitializeFromBytesArray(BufferFoto, 0, BufferFoto.Length)
countingStream.Initialize(in)
asi.WriteStream(countingStream, BufferFoto.Length)

this is the way to read the amount of bytes transferred to an other device via TCP socket.
 
Upvote 0
Top