natefinch/npipe — pull request #1 by aeckleder (2013-07-17 10:28:28+00:00)
Title: Make Go RPC work through a duplex npipe.

The catch here is that Go RPC server continuously polls for new requests (has a blocking read going on), even while a request is running (and a reply is written back to the pipe). There are two reasons why this does not work out of the box:
1) The current os.File implementation uses a Mutex to protect the file offset it is writing to / reading from, so if a blocking Read is going on, it will keep the mutex locked.
2) Windows cannot read and write to the same file handle concurrently unless overlapped I/O is used.

Also, there is the minor issue that any broken pipe error is silently being eaten by os.File.Read().

My patch switches npipe to use ReadFile and WriteFile instead of os.File, passing an Overlapped structure to do overlapped I/O. I've also added a new test case TestGoRPC() to test Go RPC over the named pipe implementation.