netutil

package
v0.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GracefulCloseConn

func GracefulCloseConn(conn net.Conn, abort <-chan struct{}, gracePeriod time.Duration)

GracefulCloseConn performs a TCP half-close (CloseWrite), giving the remote end time to read any buffered data, then fully closes after gracePeriod. The abort channel can be used to skip the grace period; if nil or never closed, the full grace period is used. Falls back to immediate close for non-TCP connections.

If conn implements StopWrites(), it is called first so that any buffered write path (e.g. bufferedConn) can flush remaining data before the TCP FIN is sent. This prevents data loss when EventDisconnect arrives shortly after a data message.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL