-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for windows named pipes by adding an xnet package containing functions for opening platform-agnostic local sockets Signed-off-by: Drew Erny <drew.erny@docker.com>
- Loading branch information
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// +build !windows | ||
|
||
package xnet | ||
|
||
import ( | ||
"net" | ||
"time" | ||
) | ||
|
||
// ListenLocal opens a local socket for control communication | ||
func ListenLocal(socket string) (net.Listener, error) { | ||
// on unix it's just a unix socket | ||
return net.Listen("unix", socket) | ||
} | ||
|
||
// DialTimeoutLocal is a DialTimeout function for local sockets | ||
func DialTimeoutLocal(socket string, timeout time.Duration) (net.Conn, error) { | ||
// on unix, we dial a unix socket | ||
return net.DialTimeout("unix", socket, timeout) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build windows | ||
|
||
package xnet | ||
|
||
import ( | ||
"net" | ||
"time" | ||
|
||
"github.com/Microsoft/go-winio" | ||
) | ||
|
||
// ListenLocal opens a local socket for control communication | ||
func ListenLocal(socket string) (net.Listener, error) { | ||
// on windows, our socket is actually a named pipe | ||
return winio.ListenPipe(socket, nil) | ||
} | ||
|
||
// DialTimeoutLocal is a DialTimeout function for local sockets | ||
func DialTimeoutLocal(socket string, timeout time.Duration) (net.Conn, error) { | ||
// On windows, we dial a named pipe | ||
return winio.DialPipe(socket, &timeout) | ||
} |