Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a IPC architecture where in i am using Named pipes,
which has N-input (senders) 1 output(receiver), but the problem is i am able to receive only 1 input data on the output side.

Server side only one receiver:

hPipe = CreateNamedPipe( 
          g_szPipeName,             // pipe name 
          PIPE_ACCESS_DUPLEX,       // 
          PIPE_TYPE_BYTE |       // message type pipe 
          PIPE_READMODE_BYTE |   // message-read mode 
          PIPE_NOWAIT,                // blocking mode 
          PIPE_UNLIMITED_INSTANCES, // max. instances  
          BUFFER_SIZE,              // output buffer size 
          BUFFER_SIZE,              // input buffer size 
          NMPWAIT_USE_DEFAULT_WAIT, // client time-out 
          &sa);                    // default security attribute 

////// Error Handling

//Read client message
     BOOL bResult = ReadFile( 
          hPipe,                // handle to pipe 
          szBuffer,             // buffer to receive data 
          sizeof(szBuffer),     // size of buffer 
          &cbBytes,             // number of bytes read 
          NULL);                // not overlapped I/O 

///////Error Handlimg




Client Side more than 1 Client:

SECURITY_ATTRIBUTES sa;
sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);

InitializeSecurityDescriptor(sa.lpSecurityDescriptor,SECURITY_DESCRIPTOR_REVISION);

// ACL is set as NULL in order to allow all access to the object.
SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, NULL, FALSE);

sa.nLength = sizeof(sa);

sa.bInheritHandle = FALSE;

hPipe = CreateFile( 
	g_szPipeName,   // pipe name 
	GENERIC_WRITE, // read and write access 
	0,              // no sharing 
	&sa,           // default security attributes
	OPEN_EXISTING,  // opens existing pipe 
	0,              // default attributes 
	NULL);          // no template file 




DWORD cbBytes;
WriteFile( 
	hPipe,                // handle to pipe 
	pf32InputFrames,
	ppInputConnections[0],
	&cbBytes,             // number of bytes written 
	NULL);                // not overlapped I/O 



By the way this is in VISTA.
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900