aboutsummaryrefslogtreecommitdiff
path: root/client/main.cpp
diff options
context:
space:
mode:
authorElwin Hammer <elwinhammer@gmail.com>2024-05-29 21:41:24 +0200
committerGitHub <noreply@github.com>2024-05-29 21:41:24 +0200
commit1f78927e2e399a504368fb9b407de12d06dddcb5 (patch)
treef80ba30274ca75704075610a39fc28930f7ac4fa /client/main.cpp
parentd7616546dd5e8ba35c2b1b1ece736bca60e0b990 (diff)
parent8894d20ff0d1c1dde69879a21e756e01bcfa5262 (diff)
Merge pull request #11 from lonkaars/masterprot/software-puzzle
Bring software-puzzle up-to-date
Diffstat (limited to 'client/main.cpp')
-rw-r--r--client/main.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/client/main.cpp b/client/main.cpp
new file mode 100644
index 0000000..5c26107
--- /dev/null
+++ b/client/main.cpp
@@ -0,0 +1,38 @@
+#include <cstdio>
+#include <cstdlib>
+#include <cstdint>
+#include <exception>
+
+#include "rl.h"
+#include "sock.h"
+
+PBSocket* sock;
+
+int main(int argc, char** argv) {
+ if (argc < 2) {
+ printf("usage: %s addr [port]\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ // parse arguments
+ char* addr = argv[1];
+ uint16_t port = 9191;
+ if (argc >= 3) port = atoi(argv[2]);
+
+ sock = new PBSocket(addr, port);
+ try {
+ // connect to TCP socket (automatically spawns thread)
+ sock->sock_connect();
+ } catch (const std::exception& e) {
+ printf("error: %s\n", e.what());
+ return EXIT_FAILURE;
+ }
+
+ // enter main CLI (using GNU readline for comfyness)
+ int ret = cli_main();
+
+ delete sock;
+
+ return ret;
+}
+