Archived

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

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

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 on other sites
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 kbifstream 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 on other sites
In may game the level file can include custom images and sounds. The file is to large to read into memory.

Useless Code

Share on other sites
AS nes8bit mentioned in the lounge, you can open the same file mutliple times for read-only access.

• 10
• 16
• 14
• 18
• 15