net: check if socket descriptor is valid
							parent
							
								
									1fde205f97
								
							
						
					
					
						commit
						d078e6bb08
					
				|  | @ -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
 | 	// This is needed so that there are no problems with reusing the
 | ||||||
| 	// same port after the application exits.
 | 	// same port after the application exits.
 | ||||||
| 	C.setsockopt(sockfd, C.SOL_SOCKET, C.SO_REUSEADDR, &one, sizeof(int)) | 	C.setsockopt(sockfd, C.SOL_SOCKET, C.SO_REUSEADDR, &one, sizeof(int)) | ||||||
| 	if sockfd == 0 { | 	if sockfd == -1 { | ||||||
| 		return error('net.socket: failed') | 		return error('net.socket: failed') | ||||||
| 	} | 	} | ||||||
| 	s := Socket{ | 	s := Socket{ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue