aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-01-20 23:47:53 -0500
committerCara Salter <cara@devcara.com>2022-01-20 23:47:53 -0500
commitc2352ee043546b518f69c615a1ece778e942e650 (patch)
tree6efe18199f0fe2810c879c9251db2897a3244604 /src/main.c
downloadcmud-c2352ee043546b518f69c615a1ece778e942e650.tar.gz
cmud-c2352ee043546b518f69c615a1ece778e942e650.zip
initial commit
yay start of a state machine and also learning sockets
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..4f848ba
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,32 @@
+/**
+ * Creates a socket for the server
+ * */
+#include "server.h"
+#include <stdio.h>
+
+/**
+ * Server entrypoint
+ *
+ * sets up everything needed to handle sockets and connections
+ * */
+int main() {
+ int err = 0;
+ server_t server = {0};
+
+ err = server_listen(&server);
+
+ if (err) {
+ printf("Failed to listen on address");
+ return err;
+ }
+
+ for (;;) {
+ err = server_accept(&server);
+ if (err) {
+ printf("Failed accepting connection");
+ return err;
+ }
+ }
+
+ return 0;
+}