From 0d6233cd4530f41c0fe7a587a79f220eee1f1680 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 21 Jun 2020 17:40:39 +0300 Subject: [PATCH] net: support for s.max_single_send_size in Socket.send/2 --- vlib/net/socket.v | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/net/socket.v b/vlib/net/socket.v index 9c45972396..5c21e12253 100644 --- a/vlib/net/socket.v +++ b/vlib/net/socket.v @@ -8,6 +8,8 @@ pub: family int typ int proto int +pub mut: + max_single_send_size int = 64000 } struct C.in_addr { @@ -223,7 +225,8 @@ pub fn (s Socket) send(buf byteptr, len int) ?int { mut dptr := buf mut dlen := len for { - sbytes := C.send(s.sockfd, dptr, dlen, msg_nosignal) + send_size := if dlen > s.max_single_send_size { s.max_single_send_size } else { dlen } + sbytes := C.send(s.sockfd, dptr, send_size, msg_nosignal) if sbytes < 0 { return error('net.send: failed with $sbytes') }