🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Sending multiple files at once

Started by
0 comments, last by SkatMan 23 years, 9 months ago
how can i send multiple files at once? I know about threads, but what should i do when i send them? should i use a separate port for each file? if so - how can i retrieve a ''free'' port? thanks, Oren.
Advertisement
Provided you''re using TCP (which for a file transfer I assume is a safe bet) and you want to send the files simultaneously then you''re going to want to open a connection for each file. You could actually fake it over a single connection (by alternately sending a chunk of one then a chunk of the other) but two is easier. The client could open two connections and request one of the files on each... You might want to check out FTP code or Web Server code to get an idea of how to handle file transfers. You actually don''t need a thread per connection -- select() (for bsd-style), and overlapped i/o and WSAWaitForMultipleEvents(), both work using a single thread. That said, multithreading blocking sockets is a lot more intuitive.

This topic is closed to new replies.

Advertisement