Advertisement

Multiple access to a file...

Started by January 13, 2001 03:36 PM
2 comments, last by Mike 24 years ago
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
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

Advertisement
In may game the level file can include custom images and sounds. The file is to large to read into memory.

Useless Code
AS nes8bit mentioned in the lounge, you can open the same file mutliple times for read-only access.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement