1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: added listen_backlog to enable custom backlog

This commit is contained in:
archanpatkar 2019-07-03 13:55:31 +05:30 committed by Alexander Medvednikov
parent 015467778d
commit 5e0ae9a429

View File

@ -88,6 +88,16 @@ pub fn (s Socket) listen() int {
return res 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 // helper method to create, bind, and listen given port number
pub fn listen(port int) Socket { pub fn listen(port int) Socket {
s := socket(AF_INET, SOCK_STREAM, 0) s := socket(AF_INET, SOCK_STREAM, 0)