Click here to Skip to main content
14,978,135 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have two applications that has a same structure and these two applications communicates values using the structure in shared memory created using CreateFileMapping, OpenFileMapping and MapViewOfFile. So Whenever a value in the structure is changed by application 1, it gets reflected in appliction 2 and viceversa. This is fine.

But the 2 applications are running in the same machine. Now I want to make the 2 applications run in separate machines connected within a LAN and I require the same functionality (i.e. Communication between the 2 applications) without any synchronization issues.

Anybody, Please suggest me the best way to implement this and also the step by step method of code to achieve this.
Posted
Comments
Richard MacCutchan 20-Sep-13 5:30am
   
You cannot use shared memory in such a situation so you need to use socket communication. Google will find you lots of samples and tutorials.
manoharbalu 20-Sep-13 7:46am
   
Let us assume that I am using socket communication.

In both the applications data can be changed by the user which should be reflected in both the applications which was done earlier using the shared memory. If Application 1 is kept server and other kept as client and if I send the structure and receive the entire structure in a thread in server with a time interval of 1 to 2 second, then the external changes by the user will not occur or updated since the thread is constantly updating the data. So the old data value remains in the struture all the time. Please suggesst me a way to solve this problem. Please note that in shared memory there were no synchronization problems since it was taken care automatically by the system.
Richard MacCutchan 20-Sep-13 8:15am
   
You will need to write some synchronisation code so that your two systems can tell which data is the most current. You would probably have to start by using some external system to provide timestamps on each message that is sent between the systems.
manoharbalu 20-Sep-13 8:29am
   
Please assume that my structure is very big around 862492 bytes. Application 1 (Server) is already connected via shared memory to a small application running in local machine which originally modifies the data (Structure) using numerous calculations. In addition to this Application 1 and Application 2 from other machine will also modify the data (Structure) input from user. Is it possible to monitor each member and index elements of the structure based on time stamp to maintain synchronization. If possible, Please provide me some details and code samples.
Richard MacCutchan 20-Sep-13 9:17am
   
I think you need to look at your design first, as this is much more complex than just exchanging a small amount of information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900