From: Kevin Day Date: Thu, 30 Nov 2023 02:57:43 +0000 (-0600) Subject: Bugfix: f_socket_connect() should require non-negative socket.id. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a55af231dacdf355323d42ba6e06f0188eb7d387;p=fll Bugfix: f_socket_connect() should require non-negative socket.id. I seem to have this one backwards. The socket.id must be something other than -1. If the socket.id is -1, then just return F_file_descriptor without error bit to designate that no descriptor is available to connect with. --- diff --git a/level_0/f_socket/c/socket.c b/level_0/f_socket/c/socket.c index 08ab88a..e44ed79 100644 --- a/level_0/f_socket/c/socket.c +++ b/level_0/f_socket/c/socket.c @@ -176,7 +176,7 @@ extern "C" { #ifndef _di_f_socket_connect_ f_status_t f_socket_connect(const f_socket_t socket) { - if (socket.id != -1) return F_file_descriptor; + if (socket.id == -1) return F_file_descriptor; if (connect(socket.id, (struct sockaddr *) &socket.address, socket.length) == -1) { if (errno == EACCES) return F_status_set_error(F_access_denied); diff --git a/level_0/f_socket/c/socket.h b/level_0/f_socket/c/socket.h index ae9dfbf..b21db7e 100644 --- a/level_0/f_socket/c/socket.h +++ b/level_0/f_socket/c/socket.h @@ -245,13 +245,17 @@ extern "C" { /** * Connect to a socket. * + * This connects the socket against socket.id. + * Check the individual read/write socket functions to confirm or deny whether or not this socket.id or socket.id_data is to be used. + * * @param socket * The socket structure. * The socket.address may point to any valid structure, like "struct sockaddr", "struct sockaddr_un", or "struct sockaddr_in". + * Only socket.id is used. * * @return * F_okay on success. - * F_file_descriptor if socket file descriptor is already connected (socket.id != -1). + * F_file_descriptor if socket file descriptor is not valid (socket.id == -1). * * F_access_denied (with error bit) on access denied. * F_available_not_address (with error bit) if address is unavailable (is non-existent or not local).