Documentation
¶
Overview ¶
Package sockerr classifies socket errors portably. On Windows, Winsock reports WSAE* codes (WSAECONNREFUSED is 10061), while the syscall.E* constants there are invented values that never match a real socket error; errors.Is(err, syscall.ECONNREFUSED) is therefore always false on Windows. Every check here matches the POSIX errno and, on Windows, its Winsock code.
Index ¶
- func ConnFromContext(ctx context.Context) net.Conn
- func EnableFastDeadPeer(ctx context.Context, timeout time.Duration)
- func EnableFastDeadPeerConn(c net.Conn, timeout time.Duration)
- func IsAddrInUse(err error) bool
- func IsConnAborted(err error) bool
- func IsConnRefused(err error) bool
- func IsConnReset(err error) bool
- func IsDescriptorExhausted(err error) bool
- func IsUnreachable(err error) bool
- func TCPSendBacklog(ctx context.Context) (int, bool)
- func TCPSendBacklogConn(c net.Conn) (int, bool)
- func WithConn(ctx context.Context, c net.Conn) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnFromContext ¶
ConnFromContext returns the innermost underlying net.Conn stored by WithConn, unwrapping TLS and listener peek wrappers.
func EnableFastDeadPeer ¶
EnableFastDeadPeer configures aggressive TCP keepalive probes and a bounded unacknowledged-retransmit timeout on the request's underlying TCP socket, if available. Non-TCP or in-memory test connections are left untouched.
func EnableFastDeadPeerConn ¶
EnableFastDeadPeerConn applies fast dead-peer detection to c when c unwraps to a *net.TCPConn.
func IsAddrInUse ¶
IsAddrInUse reports a bind to an address already in use (EADDRINUSE).
func IsConnAborted ¶
IsConnAborted reports a connection aborted locally (ECONNABORTED).
func IsConnRefused ¶
IsConnRefused reports an explicit connection refusal (ECONNREFUSED).
func IsConnReset ¶
IsConnReset reports a connection reset by the peer (ECONNRESET).
func IsDescriptorExhausted ¶
IsDescriptorExhausted reports a process or system descriptor limit (EMFILE, ENFILE).
func IsUnreachable ¶
IsUnreachable reports a missing network or host route (ENETUNREACH, EHOSTUNREACH).
func TCPSendBacklog ¶
TCPSendBacklog returns the number of unsent bytes currently queued in the kernel TCP send buffer for the request's connection, when supported by the host OS. A non-zero backlog while writing indicates real network backpressure rather than an idle socket.
func TCPSendBacklogConn ¶
TCPSendBacklogConn returns the unsent bytes queued in c's kernel TCP send buffer when c unwraps to a *net.TCPConn and the platform exposes it.
Types ¶
This section is empty.