golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/internal/socket/complete_dontwait.go (about) 1 // Copyright 2021 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 darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 7 package socket 8 9 import ( 10 "syscall" 11 ) 12 13 // ioComplete checks the flags and result of a syscall, to be used as return 14 // value in a syscall.RawConn.Read or Write callback. 15 func ioComplete(flags int, operr error) bool { 16 if flags&syscall.MSG_DONTWAIT != 0 { 17 // Caller explicitly said don't wait, so always return immediately. 18 return true 19 } 20 if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK { 21 // No data available, block for I/O and try again. 22 return false 23 } 24 return true 25 }