From a86d38298ac5516eb3356cf711a328bebfd5dcb8 Mon Sep 17 00:00:00 2001 From: "joe_zhang2006@163.com" Date: Mon, 5 Sep 2022 16:59:19 +0800 Subject: [PATCH] =?UTF-8?q?[fix]nazanet=20udp=E5=A2=9E=E5=8A=A0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9socket=E8=AF=BB=E5=92=8C=E5=86=99=E7=9A=84=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E8=AE=BE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/nazanet/udp_connection.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/nazanet/udp_connection.go b/pkg/nazanet/udp_connection.go index af5869a..ee85710 100644 --- a/pkg/nazanet/udp_connection.go +++ b/pkg/nazanet/udp_connection.go @@ -70,6 +70,20 @@ func NewUdpConnection(modOptions ...ModUdpConnectionOption) (*UdpConnection, err return c, err } +func (c *UdpConnection) SetReadBuffer(bufSize int) error { + err := c.option.Conn.SetReadBuffer(bufSize) + if err != nil { + c.Dispose() + } + return err +} +func (c *UdpConnection) SetWriteBuffer(bufSize int) error { + err := c.option.Conn.SetWriteBuffer(bufSize) + if err != nil { + c.Dispose() + } + return err +} // 阻塞直至Read发生错误或上层回调函数返回false // // @return error: 如果外部调用Dispose,会返回error