Data synchronisation issues on Virtual channels

G

Guest

Hi

Can I have many processes write to the same virtual channel?

I am doing tests to try to understand how channels work. I have a server
side exe
and a Client.DLL running together. I am exchanging data between the two
successfully.

Using one channel on one client dll I run 10 instances of my application.exe
that
resides on the server. When all 10 applications are writing and reading data
simultaneously I am finding that the process that did the write on the
channel isn't
always the process that does the read. Another process reads the data
sitting on
the channel.

Am I supposed to have one client.dll per process running on the server?

My test is very simple I pass an integer to the client DLL increment it by 1
on the
client side and return it to the server side. I do this in a for loop.

When I run one instance my output is sequential. 1,2,3,4,5,6,7....
When I run several instances of the same exe I get something that looks like
this
1,3,5,8,11, etc... Random output.

How can make make sure the the process that did the write is the one doing
the
read, and that my writes and reads are being mixed up from process to process.

Thanks for the info,
Marc
 
G

Guest

Here is the solution to the problem

From the server side wrap your calls in a mutex and use WaitForSingleObject .

Psuedo code
createmutex
WaitForSingleObject
WriteToChannel
ReadFromChannel
ReleaseMutex

This will guarantee that 2 processes will not write and read on the channel
simultaneously.

This also assumes you have control of both ends server and client.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top