Skip to content

Commit 2d20ded

Browse files
committed
net: add test for RawConn.Control on Windows
This is a followup to https://go-review.googlesource.com/37039. Updates #19435. Change-Id: Ia795bd5158d26effa56e897698208ccf73f9e0d2 Reviewed-on: https://go-review.googlesource.com/43693 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent fd25fe6 commit 2d20ded

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/net/rawconn.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import (
99
"syscall"
1010
)
1111

12-
// BUG(mikio): On NaCl, Plan 9 and Windows, the Control, Read and
13-
// Write methods of syscall.RawConn are not implemented.
12+
// BUG(mikio): On Windows, the Read and Write methods of
13+
// syscall.RawConn are not implemented.
14+
15+
// BUG(mikio): On NaCl and Plan 9, the Control, Read and Write methods
16+
// of syscall.RawConn are not implemented.
1417

1518
type rawConn struct {
1619
fd *netFD
File renamed without changes.

src/net/rawconn_windows_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package net
6+
7+
import (
8+
"syscall"
9+
"testing"
10+
)
11+
12+
func TestRawConn(t *testing.T) {
13+
c, err := newLocalPacketListener("udp")
14+
if err != nil {
15+
t.Fatal(err)
16+
}
17+
defer c.Close()
18+
cc, err := c.(*UDPConn).SyscallConn()
19+
if err != nil {
20+
t.Fatal(err)
21+
}
22+
23+
var operr error
24+
fn := func(s uintptr) {
25+
operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
26+
}
27+
err = cc.Control(fn)
28+
if err != nil || operr != nil {
29+
t.Fatal(err, operr)
30+
}
31+
c.Close()
32+
err = cc.Control(fn)
33+
if err == nil {
34+
t.Fatal("should fail")
35+
}
36+
}

0 commit comments

Comments
 (0)