diff --git a/main.c b/main.c index add143e..f2fa4a8 100644 --- a/main.c +++ b/main.c @@ -240,7 +240,7 @@ int initialize_everything(char* lua_file) { if (config.type == OCT_TYPE_SERVER) { OCT_LOG_INFO("Lua script is server type"); - if (!oct_network_server_init(config.port)) { + if (!oct_network_node_init(config.port)) { OCT_LOG_ERROR("Could not establish a socket on port %s\n", config.port); return OCT_NETWORK_ERROR; } diff --git a/oct_networking.c b/oct_networking.c index 0bd33ac..14b03df 100644 --- a/oct_networking.c +++ b/oct_networking.c @@ -14,23 +14,12 @@ struct { int needs_send; char recv_buffer[BUFFER_SIZE]; char send_buffer[BUFFER_SIZE]; - - int sock_fd; - -} oct_network_client; - -struct { - int needs_recv; - int needs_send; - char recv_buffer[BUFFER_SIZE]; - char send_buffer[BUFFER_SIZE]; - int sfd; -} oct_network_server; +} oct_network_node; -int oct_network_server_init(char* port) { - oct_network_server.needs_recv = 0; - oct_network_server.needs_send = 0; +int oct_network_node_init(char* port) { + oct_network_node.needs_recv = 0; + oct_network_node.needs_send = 0; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); @@ -57,15 +46,15 @@ int oct_network_server_init(char* port) { struct addrinfo *rp; for (rp = result; rp != NULL; rp = rp->ai_next) { - oct_network_server.sfd = socket(rp->ai_family, rp->ai_socktype, + oct_network_node.sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (oct_network_server.sfd == -1) + if (oct_network_node.sfd == -1) continue; - if (bind(oct_network_server.sfd, rp->ai_addr, rp->ai_addrlen) == 0) + if (bind(oct_network_node.sfd, rp->ai_addr, rp->ai_addrlen) == 0) break; /* Success */ - close(oct_network_server.sfd); + close(oct_network_node.sfd); } freeaddrinfo(result); @@ -75,3 +64,11 @@ int oct_network_server_init(char* port) { return 1; } + +int oct_network_recv_msg() { + return 0; +} + +int oct_network_send_msg() { + return 0; +} diff --git a/oct_networking.h b/oct_networking.h index 64d7f5f..f6adb6e 100644 --- a/oct_networking.h +++ b/oct_networking.h @@ -15,8 +15,9 @@ struct oct_network_client; struct oct_network_server; -int oct_network_client_init(); -int oct_network_server_init(char* port); -int oct_network_server_deinit(); +int oct_network_node_init(char* port); +int oct_network_node_deinit(); +int oct_network_recv_msg(); +int oct_network_send_msg(); #endif diff --git a/test_server.lua b/test_server.lua index 3c3e9f9..d73ca27 100644 --- a/test_server.lua +++ b/test_server.lua @@ -1,3 +1,5 @@ +-- Make sure to run open_card_table with -ll 3 to see output + require("oct_utils") require("termbox_defs") @@ -7,7 +9,7 @@ function oct_init() -- text["shape"] = "THIS IS A TEST SERVER"; -- text["x"] = 50; -- text["y"] = 10; - OCT_LOG_ERROR("THIS IS A TEST SERVER"); + OCT_LOG_INFO("THIS IS A TEST SERVER"); return OCT_TYPE_SERVER, OCT_NOT_NEEDS_TERMBOX; end