How to tell when the socket has received all the data?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created 2 vb.net applications in VS 2002, a server and a client using
the .net.sockets namespace. I can connect and receive data fine but the
client cannot tell when it has recived all the data from the server and close
the file.

I'm sending multiple request for data and I do not want to close the
connecting everytime the entire file has been sent from the server and then
reconnect. I'm sending binary data, is there anyway to tell the client the
size of the file the server is sending?
 
So add a piece of binary data at the beginning of the data to send with the
file size?

Does anyone know of a good book for sockets programming in VB.net?

DJTN
 
Ok, I've figured this out. Like he said, I added the file size of the file
I'm sending to the front of the binary data being sent. I then strip it out
on the other side and write the rest of the data to a stream until the stream
has reached the size of the file. Works well but you have to remember to set
your buffer sizes correctly when sending and receiving the file so you only
write the data and no extra.

DJTN
 
Back
Top