[RESOLVED] File transfer problems
I'm transferring a file from client to server.
On the client I am reading 10,000 bytes at a time and sending the 10,000 bytes using a binary writer to the stream.
On the server side I am reading these and writing it to a newly created file.
Now after lots of trial and error I have reached a 'semi working' stage. What happens is I have made a message box appear on the server side showing me the total amount of received bytes out of the total incoming file size. This message box appears every 10,000 bytes received. It appears to work flawless with the message box, except when I disable the message box from appearing it seems to not work. By not working it seems to not receive all the incoming data.
So the delay the message box is causing seems to be making it work. I am just unsure why.
Re: File transfer problems
Can you replace the Messagebox with DoEvents and see if it will work?
Re: File transfer problems
It helps a bit for smaller files. Anything over a mb or so starts to 'lose' data.
For example I sent over a 3.97mb .gif file and the server received 3.25mb of it using application.doevents in replace of the message box. Using the message box (and me just holding down enter since it kept popping up) it received the full 3.97mb.
Re: File transfer problems
I have resolved my problem. For those who may end up with my same problem in the future this is how I fixed it.
While I am far from a 'networking' specialist and not exactly sure how it works this is what happened.
Sending 10,000 bytes at a time to my target server from beginning to end of the file. Without a delay in receiving the bytes the server sometimes received parts of the file out of order. Meaning when I wrote the receiving bytes to a file I was writing the bytes in the incorrect order. My fix was to send the part # of the file with the 10,000 bytes. The first 10,000 would be part 1, 20,000 part 2 and etc. On the server I would keep track of the current part the file is expecting so if the part received wasn't the next part it would simply wait and hold that data until the server caught up the the correct part.
Ideal way to do it? I have no idea, but it works.
Re: [RESOLVED] File transfer problems
can you post full code for CLIENT/SERVER file transfer program