forked from quic-go/quic-go
pack packets into large buffers when GSO is available
This commit is contained in:
12
send_conn.go
12
send_conn.go
@@ -1,12 +1,15 @@
|
||||
package quic
|
||||
|
||||
import (
|
||||
"math"
|
||||
"net"
|
||||
|
||||
"github.com/quic-go/quic-go/internal/protocol"
|
||||
)
|
||||
|
||||
// A sendConn allows sending using a simple Write() on a non-connected packet conn.
|
||||
type sendConn interface {
|
||||
Write([]byte) error
|
||||
Write(b []byte, size protocol.ByteCount) error
|
||||
Close() error
|
||||
LocalAddr() net.Addr
|
||||
RemoteAddr() net.Addr
|
||||
@@ -40,8 +43,11 @@ func newSendConn(c rawConn, remote net.Addr, info *packetInfo) *sconn {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *sconn) Write(p []byte) error {
|
||||
_, err := c.WritePacket(p, c.remoteAddr, c.oob)
|
||||
func (c *sconn) Write(p []byte, size protocol.ByteCount) error {
|
||||
if size > math.MaxUint16 {
|
||||
panic("size overflow")
|
||||
}
|
||||
_, err := c.WritePacket(p, uint16(size), c.remoteAddr, c.oob)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user