Add batched UDP I/O on Darwin via sendmsg_x/recvmsg_x
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.
This commit is contained in:
parent
fcbb7c473b
commit
57baac9504
3 changed files with 401 additions and 2 deletions
30
conn/msgx_default.go
Normal file
30
conn/msgx_default.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//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")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue