Skip to content

Commit 04fe218

Browse files
committed
Added info on CreateNamedPipeServerStream
1 parent d02423e commit 04fe218

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

aspnetcore/grpc/interprocess-namedpipes.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to use gRPC for inter-process communication with Named pi
55
monikerRange: '>= aspnetcore-8.0'
66
ms.author: wpickett
77
ai-usage: ai-assisted
8-
ms.date: 07/01/2025
8+
ms.date: 08/01/2025
99
uid: grpc/interprocess-namedpipes
1010
---
1111
# Inter-process communication with gRPC and Named pipes
@@ -89,6 +89,35 @@ The preceding example:
8989
* Sets the <xref:System.IO.Pipes.PipeSecurity> property to control which users or groups can connect to the named pipe.
9090
* Grants read/write access to the `Users` group. Additional security rules can be added as needed for the scenario.
9191

92+
### Customize Kestrel named pipe endpoints
93+
Kestrel's named pipe support enables advanced customization, allowing you to configure different security settings for each endpoint using the <xref:System.IO.Pipes.NamedPipeServerStream.CreateNamedPipeServerStream> option. This approach is ideal for scenarios where multiple named pipe endpoints require unique access controls. The ability to customize pipes per endpoint is available starting with .NET 9.
94+
95+
An example of where this is useful is a Kestrel app that requires two pipe endpoints with different access security. The <xref:System.IO.Pipes.NamedPipeServerStream.CreateNamedPipeServerStream> option can be used to create pipes with custom security settings, depending on the pipe name.
96+
97+
```csharp
98+
99+
var builder = WebApplication.CreateBuilder();
100+
101+
builder.WebHost.ConfigureKestrel(options =>
102+
{
103+
options.ListenNamedPipe("pipe1");
104+
options.ListenNamedPipe("pipe2");
105+
});
106+
107+
builder.WebHost.UseNamedPipes(options =>
108+
{
109+
options.CreateNamedPipeServerStream = (context) =>
110+
{
111+
var pipeSecurity = CreatePipeSecurity(context.NamedPipeEndpoint.PipeName);
112+
113+
return NamedPipeServerStreamAcl.Create(context.NamedPipeEndPoint.PipeName, PipeDirection.InOut,
114+
NamedPipeServerStream.MaxAllowedServerInstances, PipeTransmissionMode.Byte,
115+
context.PipeOptions, inBufferSize: 0, outBufferSize: 0, pipeSecurity);
116+
};
117+
});
118+
119+
```
120+
92121
## Client configuration
93122

94123
`GrpcChannel` supports making gRPC calls over custom transports. When a channel is created, it can be configured with a <xref:System.Net.Http.SocketsHttpHandler> that has a custom <xref:System.Net.Http.SocketsHttpHandler.ConnectCallback>. The callback allows the client to make connections over custom transports and then send HTTP requests over that transport.

0 commit comments

Comments
 (0)