Click here to Skip to main content
12,625,447 members (36,564 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ Windows VisualC++
Hello All,
I am working on Com Server and client Communication and i got a problem while creating File on a named pipe.
The scenario is Like This,
1. Com Server Creates a named pipe.

hWritePipe = CreateNamedPipe( PIPE_NAME,        // pipe name
                                 PIPE_ACCESS_DUPLEX ,         // read/write access
                                 PIPE_TYPE_MESSAGE |          // message type pipe
                                 PIPE_READMODE_MESSAGE |      // message-read mode
                                 PIPE_NOWAIT,                 // blocking mode
                                 PIPE_UNLIMITED_INSTANCES,    // max. instances
                                 PIPE_BUFFER_SIZE,            // output buffer size
                                 PIPE_BUFFER_SIZE             // input buffer size
                                 PIPE_TIMEOUT,                // client time-out
                                 NULL);                       // attribute
ConnectNamedPipe(hWritePipe, NULL);

2. Client1 open the com server and gets the pipe name and opens it with CreateFile as follows,

handle1 = CreateFile( m_chWritePipeName,      // pipe 
GENERIC_READ|GENERIC_WRITE,     // read access
FILE_SHARE_READ|FILE_SHARE_WRITE,                               // no sharing
NULL,                           // no security attributes
OPEN_EXISTING,                  // opens existing pipe
0,                              // default attributes
NULL);   
// no template file

handle1 is proper and we are able to communicate with server

3. Open the second instance of same client say client2.Client2 also gets the pipe name and tries to open(Same CreateFile call) the pipe.But in this case we are getting Invalid handle and GetLastError() is 0xe7(All pipe instances are busy).

Is it possible to open the Named pipe by multiple process?

Thanks in advance.
Posted 30-Dec-12 19:34pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can't use the same handle in multiple processes.

MSDN seems to be down right at the moment but ask Google about the DuplicateHandle() API. My recollection is that the MSDN info tells the whole story for you.

This link[^] also seems to provide a good answer for you...
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100