how to share data between two simultaneously running programs?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2006
Posts: 2
Reputation: tiffosi is an unknown quantity at this point 
Solved Threads: 0
tiffosi tiffosi is offline Offline
Newbie Poster

how to share data between two simultaneously running programs?

 
0
  #1
Apr 18th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: how to share data between two simultaneously running programs?

 
0
  #2
Apr 18th, 2006
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.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 2
Reputation: tiffosi is an unknown quantity at this point 
Solved Threads: 0
tiffosi tiffosi is offline Offline
Newbie Poster

Re: how to share data between two simultaneously running programs?

 
0
  #3
Apr 18th, 2006
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.?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: how to share data between two simultaneously running programs?

 
0
  #4
Apr 18th, 2006
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.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC