diff --git a/conn_generic.go b/conn_generic.go index 87bec24f6..1176fd71a 100644 --- a/conn_generic.go +++ b/conn_generic.go @@ -1,4 +1,4 @@ -// +build !darwin,!linux +// +build !darwin,!linux,!windows package quic diff --git a/conn_windows.go b/conn_windows.go new file mode 100644 index 000000000..db8939837 --- /dev/null +++ b/conn_windows.go @@ -0,0 +1,37 @@ +// +build windows + +package quic + +import ( + "errors" + "fmt" + "net" + "syscall" + + "golang.org/x/sys/windows" +) + +func newConn(c net.PacketConn) (connection, error) { + return &basicConn{PacketConn: c}, nil +} + +func inspectReadBuffer(c net.PacketConn) (int, error) { + conn, ok := c.(interface { + SyscallConn() (syscall.RawConn, error) + }) + if !ok { + return 0, errors.New("doesn't have a SyscallConn") + } + rawConn, err := conn.SyscallConn() + if err != nil { + return 0, fmt.Errorf("couldn't get syscall.RawConn: %w", err) + } + var size int + var serr error + if err := rawConn.Control(func(fd uintptr) { + size, serr = windows.GetsockoptInt(windows.Handle(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF) + }); err != nil { + return 0, err + } + return size, serr +} diff --git a/go.mod b/go.mod index 052f9b663..69777592b 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/net v0.0.0-20200707034311-ab3426394381 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 google.golang.org/protobuf v1.23.0 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect )