
-----------------------------------
isaiahk9
Tue Apr 13, 2010 5:48 pm

Two programs reading/writing to the same file at one - possible?
-----------------------------------
Quick question.  My friend is currently making an eDragon (a screen-mate, similar to eSheep), and I am currently making an eKratos (as in Kratos from God of War).  However, I would like them to interact: if I turned on my eKratos program while his eDragon program was on (on the same computer), then maybe they would fight.

I believe the easiest way to do this would be to have each program write to their own text files integers representing their current state.  Then the other program would read the original program's text files, thus allowing information to be exchanged between the two programs.

One question therefore: Can two Turing programs read/edit the same text file at once?

-----------------------------------
USEC_OFFICER
Tue Apr 13, 2010 7:02 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
Maybe, but I'm sure not at the same time.

-----------------------------------
isaiahk9
Tue Apr 13, 2010 7:16 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
Hmm, that's what I'm really wondering about.
I suppose I could have the programs do some funny synchronized opening and closing of files, but that would be a major pain.

Does anybody know whether more than one program could read/write to a file at a time?

-----------------------------------
BigBear
Tue Apr 13, 2010 7:44 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
not at the exact same time. why not have two one that it reads from and one that it writes to

-----------------------------------
isaiahk9
Tue Apr 13, 2010 7:50 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
Dang.  I guess what I'll do is I'll make the programs make synchronized switches between the text files then.  Thanks for the help and advice though.

-----------------------------------
Dan
Tue Apr 13, 2010 7:52 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
http://en.wikipedia.org/wiki/File_locking

-----------------------------------
isaiahk9
Tue Apr 13, 2010 8:02 pm

RE:Two programs reading/writing to the same file at one - possible?
-----------------------------------
Thanks Hacker Dan.  The background should help with the synchronization.
