From 5e0ae9a429e74e2258a7419b02cbcdc6f34e2699 Mon Sep 17 00:00:00 2001 From: archanpatkar Date: Wed, 3 Jul 2019 13:55:31 +0530 Subject: [PATCH] net: added listen_backlog to enable custom backlog --- vlib/net/socket.v | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vlib/net/socket.v b/vlib/net/socket.v index 09ed9233c7..ffd9a5aa1b 100644 --- a/vlib/net/socket.v +++ b/vlib/net/socket.v @@ -88,6 +88,16 @@ pub fn (s Socket) listen() int { return res } +// put socket into passive mode with user specified backlog and wait to receive +pub fn (s Socket) listen_backlog(backlog int) int { + mut n := 0 + if backlog > 0 { + n = backlog + } + res := C.listen(s.sockfd, n) + return res +} + // helper method to create, bind, and listen given port number pub fn listen(port int) Socket { s := socket(AF_INET, SOCK_STREAM, 0)