Hi there!
I’ve been working with Named Pipes recently and I ran across tons of issues myself and found this post by googling.
After tons and tons of experimentation I finally got it working.
I’m posting my solution here just in case people in the future run across this thread just like I did.
First I was working with 2019.4.12 and in the Editor everything worked fine, I could create Server Pipes and Client Pipes and communicate between them.
Then the issue came when I made a Windows Build, all of a sudden the log was saying “NamedPipeServerStream is not implemented!”
However the client has no issues, it seems that NamedPipeClientStream is implemented.
And again no issues in the Editor, I don’t understand how the Editor apparently has NamedPipeServerStream implemented while the build does not.
I tried everything, updating to 2019.4.20, tried Mono, tried IL2CPP, tried .NET 2 and .NET 4, everything still said “not implemented”
The solution was swapping out to 32 bit (x86 instead of x86_64)
And with that now everything works.
So here’s my exact working Server setup:
- Unity 2019.4.20f1
- Windows
- 32bit (x86)
- Mono
- .NET 4.x
And again the client had no issues so I’m running it on my standard parameters and everything works.
Client Setup:
- Unity 2019.4.12f1
- Windows
- 64bit (x86_64)
- Mono
- .NET Standard 2.0
I create 2 pipes on the Server (one for reading and one for write) and 2 more on the Client.
Each pipe on a separate thread, 2 threads on the server and 2 threads on the client
new NamedPipeServerStream("LiveChat_SR_CW", PipeDirection.In); // ServerRead_ClientWrite
...
new NamedPipeServerStream("LiveChat_SW_CR", PipeDirection.Out); // ServerWrite_ClientRead
...
new NamedPipeClientStream(".", "LiveChat_SW_CR", PipeDirection.In); // ServerWrite_ClientRead
...
new NamedPipeClientStream(".", "LiveChat_SR_CW", PipeDirection.Out); // ServerRead_ClientWrite
Also I am not using async, not sure if that has anything to do with it.
pipeReadServer.WaitForConnection();
...
string message = streamReadString.ReadString();
I was going insane trying to solve this and finally got it working, hopefully this post can help someone in the future!
Cheers!
EDIT: I made this video documenting my process so I remember it in the future and hopefully it might help someone else who stumbles upon this post: