Click here to Skip to main content
15,922,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateNamedPipe() Pin
Member 38520241-Aug-11 23:27
Member 38520241-Aug-11 23:27 
GeneralRe: CreateNamedPipe() Pin
Richard Andrew x641-Aug-11 13:34
professionalRichard Andrew x641-Aug-11 13:34 
GeneralRe: CreateNamedPipe() Pin
Member 38520242-Aug-11 3:16
Member 38520242-Aug-11 3:16 
AnswerRe: CreateNamedPipe() Pin
Richard Andrew x641-Aug-11 13:14
professionalRichard Andrew x641-Aug-11 13:14 
GeneralRe: CreateNamedPipe() Pin
Member 38520241-Aug-11 13:17
Member 38520241-Aug-11 13:17 
GeneralRe: CreateNamedPipe() Pin
Member 38520241-Aug-11 23:03
Member 38520241-Aug-11 23:03 
AnswerRe: CreateNamedPipe() Pin
Chuck O'Toole2-Aug-11 15:38
Chuck O'Toole2-Aug-11 15:38 
I have read the entire thread so far and I think I see the problem here. The "Server" side of named pipes needs some magic in order to support multiple clients accessing it, even if those clients are "synchronized".

A named pipe is still a "one shot deal", that is, you create it, wait for a connection, accept the connection, and then close the pipe when you are all done. That means that a single "client" can access the pipe. In order for multiple clients to work, you have to have multiple instances of the "named pipe", in other words, you have lots of pipes with the same name all ready for use.

The easiest way to do this is demonstrated in the following pseudo-code (I cannot actually paste my working code as it belongs to my employer, as does my soul and first born
HANDLE P1 = create_a_named_pipe("Bob");

While (TRUE)
{
  HANDLE P2 = create_a_named_pipe("Bob"); // A "pipe in waiting"

  wait_for_a_connection(P1);
  
  // at this point, you can process the messages being passed on P1.  You can either do it in
  // this code or if you are communicating with "unsynchronized" clients, you might want to
  // create a thread to work on P1.  If you do that, make sure then make their own copy of
  // P1 because we are about to clobber it.

  // once you are done processing the communication, close the P1 handle, here or in the thread

  P1 = P2;  // switch to the waiting pipe
}
).
Anyway, you need to maintain at least one "unattached" pipe with the proper name so that clients have something to "connect to" while you are busy working with the other client or cleaning up after you are done with it.

Managing how one and only one application will have a pipe named "Bob" is an exercise for the student Smile | :)
GeneralRe: CreateNamedPipe() Pin
Member 38520242-Aug-11 22:52
Member 38520242-Aug-11 22:52 
QuestionHow a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris741-Aug-11 3:17
Arris741-Aug-11 3:17 
AnswerRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
«_Superman_»1-Aug-11 4:12
professional«_Superman_»1-Aug-11 4:12 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris741-Aug-11 6:20
Arris741-Aug-11 6:20 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
«_Superman_»1-Aug-11 6:32
professional«_Superman_»1-Aug-11 6:32 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris742-Aug-11 1:43
Arris742-Aug-11 1:43 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Albert Holguin1-Aug-11 18:00
professionalAlbert Holguin1-Aug-11 18:00 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris742-Aug-11 1:38
Arris742-Aug-11 1:38 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Albert Holguin2-Aug-11 4:02
professionalAlbert Holguin2-Aug-11 4:02 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris742-Aug-11 5:02
Arris742-Aug-11 5:02 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Arris742-Aug-11 5:48
Arris742-Aug-11 5:48 
GeneralRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
Albert Holguin2-Aug-11 6:05
professionalAlbert Holguin2-Aug-11 6:05 
AnswerRe: How a to expose data of an application (.EXE) to a DLL on runtime? Pin
jschell1-Aug-11 8:13
jschell1-Aug-11 8:13 
Questionhow to avoid dead-lock if you write multi-thread programming Pin
yu-jian1-Aug-11 2:50
yu-jian1-Aug-11 2:50 
AnswerRe: how to avoid dead-lock if you write multi-thread programming Pin
Albert Holguin1-Aug-11 3:20
professionalAlbert Holguin1-Aug-11 3:20 
QuestionSOCKET : How to gracfully stop application when recv() function is blocking Pin
pandit841-Aug-11 1:05
pandit841-Aug-11 1:05 
AnswerRe: SOCKET : How to gracfully stop application when recv() function is blocking Pin
Peter_in_27801-Aug-11 1:25
professionalPeter_in_27801-Aug-11 1:25 
JokeRe: SOCKET : How to gracfully stop application when recv() function is blocking Pin
Code-o-mat1-Aug-11 5:57
Code-o-mat1-Aug-11 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.