diff --git a/internal/socket_unix.go b/internal/socket_unix.go index 6229162..a817a2e 100644 --- a/internal/socket_unix.go +++ b/internal/socket_unix.go @@ -151,10 +151,13 @@ func connect(fd int, remoteAddr net.Addr, timeout time.Duration, opts ...sonicop return sonicerrors.ErrTimeout } - _, err = syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_ERROR) + socketErr, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_ERROR) if err != nil { return os.NewSyscallError("getsockopt", err) } + if socketErr != 0 { + return syscall.Errno(socketErr) + } } return nil