gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/net/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 // +build darwin dragonfly freebsd linux netbsd openbsd solaris 7 8 package socket 9 10 import ( 11 "syscall" 12 ) 13 14 // ioComplete checks the flags and result of a syscall, to be used as return 15 // value in a syscall.RawConn.Read or Write callback. 16 func ioComplete(flags int, operr error) bool { 17 if flags&syscall.MSG_DONTWAIT != 0 { 18 // Caller explicitly said don't wait, so always return immediately. 19 return true 20 } 21 if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK { 22 // No data available, block for I/O and try again. 23 return false 24 } 25 return true 26 }