Differences from the wireguard-go/conn:
NewStdNetBindandNewDefaultBindtake an explicitgonnect.Network.StdNetBindopens sockets through the suppliedgonnect.Networkinstead of calling the standard library listen APIs directly.- Added
StdNetBindOptions,NewStdNetBindWithOptions, andNewDefaultBindWithOptionsso callers can prefer IPv6 first or opt into single-family fallback when a sibling UDP family cannot be opened. - Added
StdNetBindOptions.BatchSizeso callers can overrideStdNetBind's effective batch size. Positive values driveBatchSize(), receive validation, native batch read/write slice lengths, and pooled message allocation; non-positive values preserve existing defaults. - Linux batch I/O, sticky ancillary data, socket marks, and similar raw-socket
features are now capability-gated so wrapped or virtual gonnect UDP
connections can fall back to ordinary
ReadMsgUDP/WriteMsgUDPAddrPort. - Non-batch
StdNetBindsends now route throughgonnect.UDPConn.WriteMsgUDPAddrPort, which keeps virtual gonnect UDP networks such as loopback compatible with endpoint sends. StdNetBindnormalizes received IPv4-mapped IPv6 peer addresses back to plain IPv4 before exposing them as endpoints.- On Windows,
WinRingBindis only selected when the supplied network is native and exposesSubscribeCloser(io.Closer); otherwiseNewDefaultBindfalls back toStdNetBind. - On Windows,
WinRingBindsizes each RIO packet slot for full UDP payloads and uses a smaller ring depth than upstream to keep the total allocation bounded while supporting larger datagrams. - When
WinRingBindis selected, it subscribes itself for external closer tracking soNetwork.Down()closes the bind. - gonnect listen control hooks may be ignored or called without raw-socket
access; bind-time controls now tolerate a nil
syscall.RawConn. - Receive functions now return
ErrReadBufferTooShortwhen the caller supplies fewer thanBatchSize()packet, size, or endpoint slots. - Added
TryUpgradeToBatchingConn, a Linux-only upgrade path from a native backedgonnect.PacketConn/gonnect.UDPConnto a standalone batched UDP socket API withReadBatchandWriteBatchTo.