errnos_windows.go 482 B

1234567891011121314151617181920212223242526
  1. package dht
  2. import (
  3. "errors"
  4. "syscall"
  5. "golang.org/x/sys/windows"
  6. )
  7. // See https://github.com/anacrolix/dht/issues/16.
  8. func ignoreReadFromError(err error) bool {
  9. var errno syscall.Errno
  10. if errors.As(err, &errno) {
  11. switch errno {
  12. case
  13. windows.WSAENETRESET,
  14. windows.WSAECONNRESET,
  15. windows.WSAECONNABORTED,
  16. windows.WSAECONNREFUSED,
  17. windows.WSAENETUNREACH,
  18. windows.WSAETIMEDOUT: // Why does Go have braindead syntax?
  19. return true
  20. }
  21. }
  22. return false
  23. }