I recently ran into issues using the NamedPipeServerStream API with .NET Core.
- In Windows, NamedPipeServerStream creates a pipe with a defined name in a specific location on the Windows filesystem (\\.pipe\\)
- In a Python client application, we were able to open this pipe for communication using the code snippet : open(r’\\.\pipe\\’ + pipe_name, ‘r+b’, 0)
- However, on Linux, the behavior for the NamedPipeServerStream API is different.
- Looking at the source code for .NET Core, I saw that NamedPipeServer/ClientStream in .NET Core are built on top of Unix domain sockets.
- So, if we want to communicate with a Python client, we have to use Python’s socket module
- C# (Server) : https://gist.github.com/abgoswam/025bbf7b845259e6cbfb0671c12b51ac
- Python (Client) : https://gist.github.com/abgoswam/7305409388e7192cf7ad2cba72296aab
- This is the PR that makes the NamedPipe*Stream API on Unix use Unix domain sockets.
- The description in the commit helped me understand the issue.
- This is a nice post on C# <-> Python bridge using Named Pipes.
- However, this technique doesn’t work for Linux (when using .NET Core). Hence I am posting this article on how to use Unix Domain sockets instead. 🙂