From d078e6bb08aff1f0a6aadf865a12334a5d84f261 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 11 Apr 2020 20:06:01 +0300 Subject: [PATCH] net: check if socket descriptor is valid --- vlib/net/socket.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/net/socket.v b/vlib/net/socket.v index 5f5009a9d3..2a1c77bad6 100644 --- a/vlib/net/socket.v +++ b/vlib/net/socket.v @@ -90,7 +90,7 @@ pub fn new_socket(family int, _type int, proto int) ?Socket { // This is needed so that there are no problems with reusing the // same port after the application exits. C.setsockopt(sockfd, C.SOL_SOCKET, C.SO_REUSEADDR, &one, sizeof(int)) - if sockfd == 0 { + if sockfd == -1 { return error('net.socket: failed') } s := Socket{