| // Copyright 2018 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. |
| // Test use of raw connections. |
| func TestRawConnReadWrite(t *testing.T) { |
| rconn, err := r.SyscallConn() |
| wconn, err := w.SyscallConn() |
| err = wconn.Write(func(s uintptr) bool { |
| _, operr = syscall.Write(syscallDescriptor(s), []byte{'b'}) |
| return operr != syscall.EAGAIN |
| err = rconn.Read(func(s uintptr) bool { |
| n, operr = syscall.Read(syscallDescriptor(s), buf) |
| return operr != syscall.EAGAIN |
| t.Errorf("read %d bytes, expected 1", n) |
| t.Errorf("read %q, expected %q", buf, "b") |