From 73af2f44516357d7ec0ba3e4da8e65a7534a9fa5 Mon Sep 17 00:00:00 2001 From: j4nk Date: Fri, 2 Jun 2023 08:25:00 -0400 Subject: [PATCH] close socket after using, remove unused forward declarations --- oct_networking.c | 3 +++ oct_networking.h | 5 +---- oct_utils.lua | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/oct_networking.c b/oct_networking.c index 5c89569..a481141 100644 --- a/oct_networking.c +++ b/oct_networking.c @@ -69,6 +69,8 @@ int oct_network_node_init(char* port, lua_State* L) { return 0; } + OCT_LOG_INFO("Listening on 127.0.0.1 port %s", port); + lua_pushcfunction(L, oct_network_recv_msg_lua); lua_setglobal(L, "oct_recv"); lua_pushcfunction(L, oct_network_send_msg_lua); @@ -147,6 +149,7 @@ int oct_network_send_msg() { return -1; } oct_network_node.needs_send = 0; + close(sfd); } return 1; } diff --git a/oct_networking.h b/oct_networking.h index 3d4b337..282f395 100644 --- a/oct_networking.h +++ b/oct_networking.h @@ -5,13 +5,10 @@ #include #define BUFFER_SIZE 1024 +#define NUM_BUFFERS 10; #define OCT_DEFAULT_PORT "20000" -// Forward declarations -struct oct_network_client; -struct oct_network_server; - int oct_network_node_init(char* port, lua_State* L); int oct_network_node_deinit(); diff --git a/oct_utils.lua b/oct_utils.lua index 5cb3c41..95f75a3 100644 --- a/oct_utils.lua +++ b/oct_utils.lua @@ -1,3 +1,9 @@ +-- Useful constants +OCT_NEEDS_NETWORKING = 1; +OCT_NOT_NEEDS_NETWORKING = 0; +OCT_NEEDS_TERMBOX = 1; +OCT_NOT_NEEDS_TERMBOX = 0; + -- Load a sprite stored in a .txt file function load_termbox_sprite(file_name) file = io.open(file_name, "r"); @@ -7,8 +13,4 @@ function load_termbox_sprite(file_name) return contents; end -OCT_NEEDS_NETWORKING = 1; -OCT_NOT_NEEDS_NETWORKING = 0; -OCT_NEEDS_TERMBOX = 1; -OCT_NOT_NEEDS_TERMBOX = 0;