StdNetBind implements Bind for all platforms. While Windows has its own Bind (see bind_windows.go), it may fall back to StdNetBind. TODO: Remove usage of ipv{4,6}.PacketConn when net.UDPConn has comparable methods for sending and receiving multiple datagrams per-syscall. See the proposal in https://
| 30 | // methods for sending and receiving multiple datagrams per-syscall. See the |
| 31 | // proposal in https://github.com/golang/go/issues/45886#issuecomment-1218301564. |
| 32 | type StdNetBind struct { |
| 33 | mu sync.Mutex // protects all fields except as specified |
| 34 | ipv4 *net.UDPConn |
| 35 | ipv6 *net.UDPConn |
| 36 | ipv4PC *ipv4.PacketConn // will be nil on non-Linux |
| 37 | ipv6PC *ipv6.PacketConn // will be nil on non-Linux |
| 38 | ipv4TxOffload bool |
| 39 | ipv4RxOffload bool |
| 40 | ipv6TxOffload bool |
| 41 | ipv6RxOffload bool |
| 42 | |
| 43 | // these two fields are not guarded by mu |
| 44 | udpAddrPool sync.Pool |
| 45 | msgsPool sync.Pool |
| 46 | |
| 47 | blackhole4 bool |
| 48 | blackhole6 bool |
| 49 | } |
| 50 | |
| 51 | func NewStdNetBind() Bind { |
| 52 | return &StdNetBind{ |
nothing calls this directly
no outgoing calls
no test coverage detected