Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Large files and WinSock...

This topic is 6506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When a user joins my game and does not have the custom level that the person hosting the game is using, I want the other person to automatically recieve the custom level. I''m wondering how one should go about sending a large file over the internet using WinSock. I supose I might be able to use WinInet for FTP, but I''d rather not. It seems to me that it would be posible to just load the file into memory and send it with "send". Clearly this is not the best method due to the fact the file might be 10 meg or so in size. I''m thinking the be course of action would be to open the file in binary mode, read in a chunk of the file, and send that chunk to the other computer. Once the other computer has recieved that chunk then the next chunk will get sent. This method leaves me with two questions. Once, how big can a chunk be? Should I get the maximum packet size and just use that? Also, can I just have a loop in the server sending piece after piece or should the server wait for a message from the client saying that the client has recieved the prevoius chunk? Thanks, Mike

Share this post

Link to post
Share on other sites
Well, first off, if you try to send the entire file in one send() call, the send function will regurgitate and only send part of the file. It will report the number of bytes it did send, so you can just advance your pointer into the file and resend from there.

For the read in by chunks concept, there are two schools of thought: one is to send the largest chunk possible at any given time. i.e. keep on sending more information that send can properly handle and use the return value to adjust the number of bytes sent next time. The other school of thought is to send packets so that the network layer packets is the same size as the minimum MTU you might run across. I''m personnally more of the second school of thought.

Also, if you use TCP, the client message facility is built into the protocol. (ACKs are your friend.) Considering that you''re sending a file, which depends on packets arriving reliable as well as in order, TCP seems like the perfect choice.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!