Allow server to start on tcp port or if windows, named pipe rather than unix socket. could not yet make it work on named pipe from js client (connects but error)

This commit is contained in:
guillaume.tardif 2020-05-16 16:39:08 +02:00 • committed by Guillaume Tardif
parent 23d2eacf84
commit ecfffc6feb
6 changed files with 55 additions and 5 deletions

22
server/socket_windows.go Normal file
View file

@ -0,0 +1,22 @@
// +build windows
package server
import (
"errors"
"net"
"strings"
"github.com/Microsoft/go-winio"
)
func createLocalListener(address string) (net.Listener, error) {
if !strings.HasPrefix(address, "npipe://") {
return nil, errors.New("Cannot parse address, must start with npipe:// or tcp:// : " + address)
}
return winio.ListenPipe(strings.TrimPrefix(address, "npipe://"), &winio.PipeConfig{
MessageMode: true, // Use message mode so that CloseWrite() is supported
InputBufferSize: 65536, // Use 64KB buffers to improve performance
OutputBufferSize: 65536,
})
}