Jump to content
  • Advertisement

Archived

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

Mike

Multiple access to a file...

This topic is 6517 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

Lets say I have two clients connected to the server an they both need to download the new level. What is the most eligant way to have the two clients recieve the file at the same time? I know that I could just keep track of how far along each client is in the file and seek to that position, and keep track of how many clients have access to the file so that I don't close it to early, but I'm wondering if there is a better way. Is there? Useless Code What I said above isn't very clear. I know how to send the files, and I could get it to work using fseek. I'm just wondering if there is a better way to read in from the file without haveing to seek to each client's position. I know you can't do this, but I'm wondering if there is something like: FILE* file1 = fopen... FILE* file2 = fopen... Edited by - Mike on January 13, 2001 5:08:22 PM

Share this post


Link to post
Share on other sites
Advertisement
if the file isnt too big......you could just already have all the info from the file loaded into memory. Say the file is 10 kb then you could do this when you start up the server
  
char* buff = new char[10*1024]; // that is 10 kb

ifstream infile;
infile.open(filename, ios::binary);
infile.read((char*)buff, 1081024);
infile.close();


now have a separate thread for each client and send the data in buff to each client


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
We are creating a Multi-player space strategy/shoot-em-up/RPG game.
Development is well under way and we do have a playable demo.
Always looking for help.
Digital Euphoria Soft

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!