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 //go:build baremetal || moxie.wasm || nintendoswitch || wasm_unknown
6 7 package syscall
8 9 // A RawConn is a raw network connection.
10 type RawConn interface {
11 // Control invokes f on the underlying connection's file
12 // descriptor or handle.
13 // The file descriptor fd is guaranteed to remain valid while
14 // f executes but not after f returns.
15 Control(f func(fd uintptr)) error
16 17 // Read invokes f on the underlying connection's file
18 // descriptor or handle; f is expected to try to read from the
19 // file descriptor.
20 // If f returns true, Read returns. Otherwise Read blocks
21 // waiting for the connection to be ready for reading and
22 // tries again repeatedly.
23 // The file descriptor is guaranteed to remain valid while f
24 // executes but not after f returns.
25 Read(f func(fd uintptr) (done bool)) error
26 27 // Write is like Read but for writing.
28 Write(f func(fd uintptr) (done bool)) error
29 }
30 31 // Conn is implemented by some types in the net and os packages to provide
32 // access to the underlying file descriptor or handle.
33 type Conn interface {
34 // SyscallConn returns a raw network connection.
35 SyscallConn() (RawConn, error)
36 }
37