net: check if socket descriptor is valid

pull/4356/head
Alexey 2020-04-11 20:06:01 +03:00 committed by GitHub
parent 1fde205f97
commit d078e6bb08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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{