From b1b94e828f477b384eb36a8cee9e511069ee77a5 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Tue, 28 Apr 2026 00:06:58 +0200 Subject: Adds native server and client (WIP) --- core/client.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 core/client.c (limited to 'core/client.c') diff --git a/core/client.c b/core/client.c new file mode 100644 index 0000000..220a90c --- /dev/null +++ b/core/client.c @@ -0,0 +1,28 @@ +#include +#include + +#include "logger.c" + +int main(void) { + log_info("Initializing salis data client"); + int client_fd = socket(AF_INET, SOCK_STREAM, 0); + struct sockaddr_in server_addr = { 0 }; + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = inet_addr(IP); + server_addr.sin_port = htons(PORT); + + log_info("Attempting to connect to salis data server at: %s:%d", IP, PORT); + if (connect(client_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_in))) { + log_warn("Could not connect to salis data server!"); + return 1; + } + + log_info("Fetching simulation info"); + write(client_fd, "o", sizeof(char)); + struct json_object *response = json_object_from_fd(client_fd); + const char *str_rep = json_object_to_json_string_ext(response, JSON_C_TO_STRING_PRETTY); + printf("resp: %s\n", str_rep); + + close(client_fd); + return 0; +} -- cgit v1.3