Solved

Using _pipe in Windows application

Posted on 2013-06-12
1
267 Views
Last Modified: 2013-08-20
Can one ue the function '_pipe' as a named pipe between applications whree there is NOT a parent/child relationship?

I have two applications that I want to have interprocess communications. One app, we'll call the server, creates the anmed pipe and the other app, we'll call the client, gets the file descriptors to the pipe by using CFile::Open then Cfile::Read. The client can start/stop at different times and is independent of the server.

So atain can '_pipe" be used in the above situation?

Thanks
0
Comment
Question by:atomicgs12
1 Comment
 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 39243866
a pipe only can be used between parent and child process cause a call to _pipe returns two handles (one for read, one for write) and the parent would pass one of the handles to its child process it has spawned. if the second process is not a child process, it cannot inherit a handle from a process that is not its parent.

see the sample code in http://msdn.microsoft.com/en-us/library/aa298531(v=VS.60).aspx

instead of pipes you could use shared memory. you would create named shared memory by either program calling CreateMemoryMappedFile. the second of client or server would get a handle to the already created memory. a memory mapped file would be a piece of memory where client and server could write or read from. synchronisation would be made by a mutex.

see http://msdn.microsoft.com/en-us/library/dd997372.aspx for more information.

if both server and client have a windows message loop (a win32 process can run a message loop even if it runs in background) you could use windows messages for p2p communication, for example by using global memory and sending/receiving a handle to that memory by message.

Sara
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best way to accomplish this task? 3 93
Problem to file 3 92
How to code SharePoint 2013 online 4 93
Where did System.Data.Objects go? 2 60
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question