Hi all,

I am trying to share data between two simultaneously running programs. I am writing the output of one program to a file named xpos.out and reading the data in it from an other program which is running simultaneously. The value in xpos.out changes each time. So when i try to read this in the next cylce i never get the updated value.

I am following a simple procedure:
In one program iam writing it to xpos.out and immidiately closing it. and in another program iam reading the data in xpos.out. Only the first value is getting repeated.

Any help regarding this would be highly regarded...

Thanking you,
Prasad.

Well unless you are reading and writing at the same time, there shouldn't be any problem.

That is if it cycles like

Process A - Write File
Process A - Close File
Process B - Read File
Process B - Close File
Repeat from above

There are mechanisms by the operating systems for processes to communicate with eachother. One of the easiest way is to use a socket. Make a connection between the processes through a socket and then write the data to the socket. The recieving process can then read from the socket when there is data available.

i am working on linux platform (Fedora Core 4) and am new to socket programming. And this is what i exactly want. Iam running one of my programs on port no. 6665 and the other on port no. 6666 so can u let me know how to share information using socket programming.?

Have a look at this site. It is known as one of the best for introducing socket programming. Also it should work without any trouble in Linux with gcc.

Edit:
Both programs should be using the same port. One should be the server and the other should be the client.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.