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