| // Copyright 2017 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestRawConn(t *testing.T) { |
| c, err := newLocalPacketListener("udp") |
| cc, err := c.(*UDPConn).SyscallConn() |
| operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) |
| if err != nil || operr != nil { |
| func TestRawConnListener(t *testing.T) { |
| ln, err := newLocalListener("tcp") |
| cc, err := ln.(*TCPListener).SyscallConn() |
| op := func(uintptr) bool { |
| t.Error("Write should return an error") |
| t.Error("Write shouldn't call op") |
| t.Error("Read should return an error") |
| t.Error("Read shouldn't call op") |
| l = int32(unsafe.Sizeof(v)) |
| operr = syscall.Getsockopt(syscall.Handle(s), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, (*byte)(unsafe.Pointer(&v)), &l) |
| if err != nil || operr != nil { |
| t.Fatal("Control after Close should fail") |