local_socket/socket_windows.go

27 lines
592 B
Go
Raw Normal View History

2017-10-24 02:57:54 +00:00
package local_socket
mport (
"gopkg.in/natefinch/npipe.v2"
)
// LocalSocket is a socket to communicate with other processes in the same box.
// LocalSocket satisfies io.Reader, io.Writer, net.Conn interfaces.
type LocalSocket struct {
*npipe.PipeConn
}
// NewLocalSocket creates LocalSocket instance
func NewLocalSocket(pathName string) (*LocalSocket, error) {
conn, err := npipe.Dial(`\\.\pipe\` + pathName)
if err != nil {
return nil, err
}
return newLocalSocket(conn), nil
}
func newLocalSocket(conn *npipe.PipeConn) *LocalSocket {
return &LocalSocket{
PipeConn: conn,
}
}