MCPcopy
hub / github.com/golang/net / ReadBatch

Method ReadBatch

ipv4/batch.go:74–97  ·  view source on GitHub ↗

ReadBatch reads a batch of messages. The provided flags is a set of platform-dependent flags, such as syscall.MSG_PEEK. On a successful read it returns the number of messages received, up to len(ms). On Linux, a batch read will be optimized. On other platforms, this method will read only a single

(ms []Message, flags int)

Source from the content-addressed store, hash-verified

72// must be large enough to accommodate an IPv4 header and option
73// headers.
74func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
75 if !c.ok() {
76 return 0, errInvalidConn
77 }
78 switch runtime.GOOS {
79 case "linux":
80 n, err := c.RecvMsgs([]socket.Message(ms), flags)
81 if err != nil {
82 err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
83 }
84 return n, err
85 default:
86 n := 1
87 err := c.RecvMsg(&ms[0], flags)
88 if err != nil {
89 n = 0
90 err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
91 }
92 if compatFreeBSD32 && ms[0].NN > 0 {
93 adjustFreeBSD32(&ms[0])
94 }
95 return n, err
96 }
97}
98
99// WriteBatch writes a batch of messages.
100//

Callers

nothing calls this directly

Calls 6

okMethod · 0.95
adjustFreeBSD32Function · 0.85
RecvMsgsMethod · 0.80
RecvMsgMethod · 0.80
LocalAddrMethod · 0.65
NetworkMethod · 0.45

Tested by

no test coverage detected