| 1 |
// Copyright 2015 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 !plan9 && !windows |
| 6 |
|
| 7 |
package net |
| 8 |
|
| 9 |
import ( |
| 10 |
"errors" |
| 11 |
"os" |
| 12 |
"syscall" |
| 13 |
) |
| 14 |
|
| 15 |
var ( |
| 16 |
errTimedout = syscall.ETIMEDOUT |
| 17 |
errOpNotSupported = syscall.EOPNOTSUPP |
| 18 |
|
| 19 |
abortedConnRequestErrors = []error{syscall.ECONNABORTED} // see accept in fd_unix.go |
| 20 |
) |
| 21 |
|
| 22 |
func isPlatformError(err error) bool { |
| 23 |
_, ok := err.(syscall.Errno) |
| 24 |
return ok |
| 25 |
} |
| 26 |
|
| 27 |
func samePlatformError(err, want error) bool { |
| 28 |
if op, ok := err.(*OpError); ok { |
| 29 |
err = op.Err |
| 30 |
} |
| 31 |
if sys, ok := err.(*os.SyscallError); ok { |
| 32 |
err = sys.Err |
| 33 |
} |
| 34 |
return err == want |
| 35 |
} |
| 36 |
|
| 37 |
func isENOBUFS(err error) bool { |
| 38 |
return errors.Is(err, syscall.ENOBUFS) |
| 39 |
} |