I used named pipe for internal communication inside of one program (on Windows XP). The named pipe works fine for multiple connections when I connected 2-3 clients. However it seems to be jammed when I apply several connections concurrently (for example 10), only a few of connections could be accepted by ConnectNamedPipe() and The communication seems to be jammed.
But when I debugged in client code, I found out that all client CreateFile functions returned correctly with file handles (seems to be correct ones). It is confusing since I watched the CreateNamedPipe loop and it only creates about half of the handles...
Server Part:
while (!isPipeServerClosed)
{
try
{
filehandle = CreateNamedPipe(
this.pipeName,
DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
255,
InBufferSize,
InBufferSize,
0,
IntPtr.Zero);
if (ConnectNamedPipe(filehandle, IntPtr.Zero) > 0)
{
PipeThread pipe = new PipeThread(filehandle);
sPipeThreadList.Add(pipe);
}
}
catch (Exception exp)
{
System.Console.WriteLine(exp.StackTrace);
}
}
Client Part, simple Delphi code (behaves the same even when I tried with WaitNamedPipe ):
FHandle := INVALID_HANDLE_VALUE;
FHandle := CreateFile(PChar(FPipeName),GENERIC_READ or GENERIC_WRITE,
0,0,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);
// create the class
if FHandle = INVALID_HANDLE_VALUE then
begin
Connected := false;
end
Could I know what did I miss? Thank you!