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

net: check if socket descriptor is valid

This commit is contained in:
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

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{