On a connected socket sendmsg_x sends a whole batch in one syscall; msg_name is unsupported there, so batched sends require connecting to the peer, which loses roaming and is therefore opt-in via SetSinglePeerMode for single fixed-peer binds. recvmsg_x fills in per-message source addresses, so batched receive works on unconnected sockets too. Any unexpected errno permanently falls back to the generic paths. iOS is excluded: in the Network Extension recvmsg_x on unconnected UDP sockets delivers no data, and connected sockets stop passing traffic after a rebind.
30 lines
577 B
Go
30 lines
577 B
Go
//go:build !darwin || ios
|
|
|
|
package conn
|
|
|
|
import (
|
|
"net"
|
|
|
|
"golang.org/x/net/ipv6"
|
|
)
|
|
|
|
const supportsMsgX = false
|
|
|
|
const msgXBatchSize = 1
|
|
|
|
type msgXState struct{}
|
|
|
|
func (m *msgXState) reset() {
|
|
}
|
|
|
|
// SetSinglePeerMode is a no-op on platforms without sendmsg_x/recvmsg_x.
|
|
func (s *StdNetBind) SetSinglePeerMode() {
|
|
}
|
|
|
|
func (s *StdNetBind) sendMsgX(conn *net.UDPConn, msgs []ipv6.Message) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (s *StdNetBind) makeReceiveMsgX(conn *net.UDPConn, isV6 bool) (ReceiveFunc, error) {
|
|
panic("makeReceiveMsgX is not supported on this platform")
|
|
}
|