about summary refs log tree commit diff
path: root/src/main.c
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-10-09 11:07:32 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-10-09 11:07:32 +0100
commit7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48 (patch)
tree3da6360fb34c2f33ee54cc10f880cd7e6caafab4 /src/main.c
downloadOSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.tar.gz
OSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.tar.bz2
OSCDRP-7d7ef42995aee8c14cdc2b7c93e7f60c85e69f48.zip
Release HEAD master
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..520cff3
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,32 @@
+#include <protocol.h>
+#include <utils.h>
+
+int main(int argc, char** argv)
+{
+    socket_info_t socket_info;
+    strncpy(socket_info.address, "127.0.0.1", sizeof(socket_info.address));
+    socket_info.port = 12345;
+
+    uint64_t packet_id = 1;
+    uint64_t data_size = 20000;
+    uint8_t* data = generate_random_data(data_size);
+
+    Packet_t* packet = generate_packet(packet_id, data, data_size);
+    free(data);
+
+    pthread_t wait_for_packet_thread;
+    pthread_create(&wait_for_packet_thread, NULL, (void*)wait_for_packet, &socket_info);
+
+    sleep(2); //wait until the wait_for_packet_thread is running
+    send_packet(&socket_info, (void*)packet, get_packet_size_without_data() + packet->data_size);
+    free(packet);
+
+    Packet_t* return_packet = NULL;
+    pthread_join(wait_for_packet_thread, (void**)&return_packet);
+
+    handle_packet(return_packet);
+
+    free(return_packet);
+
+    return 0;
+}