Working with named pipes in Windows (C ++ / C #)

I have a C ++ application that should send images from a webcam in real time to a C # application on the same PC. C ++ code cannot be called from C # code, so I need to implement communication through named pipes to send images.

I had never programmed communications before, and I was wondering how to approach this problem.

My first thoughts were for the C ++ application to create a named pipe channel in a separate stream, after creating the stream will wait continuously until the image is available for sending. At that moment he will send the image.

Similarly, a C # application would create a new thread that acts as a client. It will continuously connect to the server and circuit until the image is available. At this point, he will receive the image and save it in the queue, which can be accessed by the main thread.

It makes sense? Is this a better approach?
+4
source share
1 answer

Secondly, the concept of using COM is here. I would write a COM object in C #, to be honest, because it is simpler (than C ++). C # has excellent COM compatibility. See http://msdn.microsoft.com/en-us/library/aa645712%28v=vs.71%29.aspx . I wrote the working interface of MS VSS COM, which was called by Python (our build system), interacting with the C # .NET interface open by another provider; because it was low COM, it could also be called from JScript, C ++, etc.

If you are not going to interact between machines and / or need Windows security, I would avoid named pipes, although what you actually use to transfer through your object can be any possible dictated size / speed involved.

0
source

Source: https://habr.com/ru/post/1400601/


All Articles