Source File
transport.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/net/reuseport
// Package reuseport provides a basic transport for automatically (and intelligently) reusing TCP ports.//// To use, construct a new Transport and configure listeners tr.Listen(...).// When dialing (tr.Dial(...)), the transport will attempt to reuse the ports it's currently listening on,// choosing the best one depending on the destination address.//// It is recommended to set SO_LINGER to 0 for all connections, otherwise// reusing the port may fail when re-dialing a recently closed connection.// See https://hea-www.harvard.edu/~fine/Tech/addrinuse.html for details.package reuseportimport (logging)var log = logging.Logger("reuseport-transport")// ErrWrongProto is returned when dialing a protocol other than tcp.var ErrWrongProto = errors.New("can only dial TCP over IPv4 or IPv6")// Transport is a TCP reuse transport that reuses listener ports.// The zero value is safe to use.type Transport struct {v4 networkv6 network}type network struct {mu sync.RWMutexlisteners map[*listener]struct{}dialer *dialer}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |