diff --git a/main.c b/main.c
index 6197e7f..3ab8e34 100644
--- a/main.c
+++ b/main.c
@@ -16,9 +16,11 @@
* .
*/
+#include
#include
#include
#include
+#include
#include
static bool exit_requested = false;
@@ -43,11 +45,31 @@ int main(int argc, char *argv[])
return 1;
}
+ int sfd = socket(AF_INET6, SOCK_STREAM, 0);
+ if (sfd == -1) {
+ fprintf(stderr, "Failed to open socket\n");
+ return 1;
+ }
+
+ const struct sockaddr_in6 haddr = {
+ .sin6_family = AF_INET6,
+ .sin6_port = htons(7070),
+ .sin6_addr = IN6ADDR_LOOPBACK_INIT,
+ };
+ if (bind(sfd, (const struct sockaddr *)&haddr, sizeof(haddr)) == -1) {
+ fprintf(stderr, "Error binding socket to address\n");
+ return 1;
+ }
+ if (listen(sfd, 8) == -1) {
+ fprintf(stderr, "Error attempting to listen on socket\n");
+ return 1;
+ }
+
while (!exit_requested) {
sleep(1);
}
- printf("After loop\n");
+ close(sfd);
return 0;
}