add a function to set the UDP send buffer size

This function is the equivalent to the function used to set the UDP
receive buffer size. It's so similar that code generation is used to
make a copy of the setReceiveBuffer function.
This commit is contained in:
Marten Seemann 2023-05-08 14:19:57 +03:00
parent 600502ab06
commit 74be4d2755
10 changed files with 150 additions and 8 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/quic-go/quic-go/internal/utils"
)
//go:generate sh -c "echo '// Code generated by go generate. DO NOT EDIT.\n// Source: sys_conn_buffers.go\n' > sys_conn_buffers_write.go && sed -e 's/SetReadBuffer/SetWriteBuffer/g' -e 's/setReceiveBuffer/setSendBuffer/g' -e 's/inspectReadBuffer/inspectWriteBuffer/g' -e 's/protocol\\.DesiredReceiveBufferSize/protocol\\.DesiredSendBufferSize/g' -e 's/forceSetReceiveBuffer/forceSetSendBuffer/g' -e 's/receive buffer/send buffer/g' sys_conn_buffers.go | sed '/^\\/\\/go:generate/d' >> sys_conn_buffers_write.go"
func setReceiveBuffer(c net.PacketConn, logger utils.Logger) error {
conn, ok := c.(interface{ SetReadBuffer(int) error })
if !ok {