|
Post by ezmoney on Jan 5, 2013 16:27:45 GMT -5
I am looking for code for message passing between programs.. Anybody done that ?
|
|
|
Post by stormforce5 on Jan 14, 2013 5:18:59 GMT -5
I have done that, the method I used was to use a temp file which program 1 creates and program 2 reads...
if your programs/apps are used by individual users, then use ip address of of that client/user in the temp file name too...
hope that helps
|
|
|
Post by ezmoney on Feb 3, 2013 8:39:44 GMT -5
What do you do if you have multiple reading programs say 10..or 20 or... any number of reader programs? What if there are 1000's of users ? How do you give each a chance but block them from opening the same file at the same time? Is there a sleep state to put the reader program into untill the next program awaiting input can then retrive input...
It would be like a husban and wife taking money out of the bank at the same time. If you only had 500 dollars in the bank and each drawed out 300 then the account would go negative... Thus somebody is only going to get what is left over...
But this is much different as 1000's may draw from the resources in the account.
What kind of wait or state did you put program 2 into while waiting for the next event? this could burn a lot of machine cycles testing for some condition...
Is there a sleep state?
open and read accordingly.
|
|
|
Post by richardbaggett on Feb 10, 2013 21:18:46 GMT -5
As for communication, I use runbasic AND libertyBasic. There is a dll called mesock that can be used with Libertybasic to allow some socket programming. Runbasic is a web application, it doesn't even need mesock. Every computer has a loopback, localhost, or 127.0.0.1...'Nuff said.
As for file locking, I like the 'nix solution of using a 'lock' file. this is just a dummy file with perhaps an extension of '.lock'. When you want to access a file, for instance "data.dat", you first check for the presence of "data.dat.lock", if it does not exist, create it, and use the "data.dat" file. When you are done, simply kill the empty "data.dat.lock" file, and it is released for use by a different thread.
Just be prepared for error when creating the file, it is a certainty that it will eventually be created by a different thread between the time you check for it, and try to create it.
|
|