-#include <level_0/socket.h>
+#include <level_1/socket.h>
#ifdef __cplusplus
extern "C"{
#endif
#ifndef _di_fl_socket_file_bind_
- f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, f_socket_address *socket_address) {
- memset(&socket_address, 0, structure_socket_length);
- socket_address.sun_family = SOCKET_FAMILY;
- strncpy(socket_address.sun_path, socket_path, sizeof(socket_address.sun_path) - 1);
+ f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, struct sockaddr_un *socket_address) {
+ memset(&socket_address, 0, sizeof(struct sockaddr_un));
+ socket_address->sun_family = AF_UNIX;
+ strncpy(socket_address->sun_path, socket_path, sizeof(socket_address->sun_path) - 1);
- if (bind(*socket_id, (f_socket_address *) socket_address, structure_socket_length) < 0) {
+ if (bind(*socket_id, (struct sockaddr *) socket_address, sizeof(struct sockaddr_un)) < 0) {
if (errno == EACCES) {
return f_access_denied;
}
#ifndef _di_fl_socket_close_client_
// terminate a socket connection.
- f_return_status fl_socket_close_client(const f_socket_id socket_id_client, const f_socket_close_id close_action = f_socket_close_fast) {
+ f_return_status fl_socket_close_client(const f_socket_id socket_id_client, const f_socket_close_id close_action) {
f_u_int error_code = 0;
if (close_action == f_socket_close_fast) {
}
if (error_code > 0) {
- if (result == EBADF) {
+ if (error_code == EBADF) {
return f_file_descriptor_error;
}
- else if (result == EINVAL) {
+ else if (error_code == EINVAL) {
return f_invalid_value;
}
- else if (result == ENOTCONN) {
+ else if (error_code == ENOTCONN) {
return f_not_connected;
}
- else if (result == ENOTSOCK) {
+ else if (error_code == ENOTSOCK) {
return f_invalid_socket;
}
- else if (result == EINTR) {
+ else if (error_code == EINTR) {
return f_interrupted;
}
- else if (result == EBADF) {
+ else if (error_code == EBADF) {
return f_input_output_error;
}
*
* Provide means to connect to and use sockets.
*/
-#ifndef _F_socket_h
-#define _F_socket_h
+#ifndef _FL_socket_h
+#define _FL_socket_h
// libc includes
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <unistd.h>
// fll includes
#include <level_0/errors.h>
#include <level_0/strings.h>
#include <level_0/types.h>
+#include <level_0/socket.h>
#ifdef __cplusplus
extern "C"{
/**
* bind a socket.
*/
- extern f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, f_socket_address *socket_address);
+ extern f_return_status fl_socket_file_bind(const f_string socket_path, f_socket_id *socket_id, struct sockaddr_un *socket_address);
#endif // _di_fl_socket_file_bind_
#ifndef _di_fl_socket_listen_
} // extern "C"
#endif
-#endif // _F_socket_h
+#endif // _FL_socket_h