net: added listen_backlog to enable custom backlog

pull/959/head
archanpatkar 2019-07-03 13:55:31 +05:30 committed by Alexander Medvednikov
parent 015467778d
commit 5e0ae9a429
1 changed files with 10 additions and 0 deletions

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)