]> git.mdlowis.com Git - proto/aos.git/commitdiff
cleaned up listen error code handling
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 10 Dec 2020 18:23:21 +0000 (13:23 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 10 Dec 2020 18:23:21 +0000 (13:23 -0500)
.gitignore
bin/dial.c
bin/listen.c
lib/net/netdial.c [new file with mode: 0644]

index 26fa21f12f10e874b1d98db051eb806dd1c25cd7..9c35be07ae330765665f598bdeb6e9c4adb8c445 100644 (file)
@@ -1,2 +1,3 @@
 build/
 build.bin
+tags
index cbfdb1c54dad327ce77458d25d3268bcbaddbe3c..678ec59b2faeab8c86756617a49e8cece4f30981 100644 (file)
@@ -1,3 +1,6 @@
+#include <liba.h>
+#include <libnet.h>
+
 int main(int argc, char** argv)
 {
     (void)argc;
index be58c80851e702d1a8fbd9ec5d19d82d26b86599..fddd67381bd0c7ff7e7877446bed30febd000eb1 100644 (file)
@@ -5,17 +5,17 @@
 
 void serve(int cfd, char** argv)
 {
-    switch (fork())
+    int pid = fork();
+    if (pid < 0)
     {
-        case -1:
-            perror("fork");
-            break;
-        case 0:
-            dup2(cfd, 0); dup2(cfd, 1); dup2(cfd, 2);
-            exit(execvp(argv[0], argv));
-            break;
-        default:
-            break;
+        perror("fork");
+    }
+    else if (pid == 0)
+    {
+        dup2(cfd, 0);
+        dup2(cfd, 1);
+        dup2(cfd, 2);
+        exit(execvp(argv[0], argv));
     }
     close(cfd);
 }
diff --git a/lib/net/netdial.c b/lib/net/netdial.c
new file mode 100644 (file)
index 0000000..e9544e2
--- /dev/null
@@ -0,0 +1,22 @@
+#include <liba.h>
+#include <libnet.h>
+
+//int netdial(char* dialstr)
+//{
+//    struct socket_t sock = { .fd = -1 };
+//    if (netsocket(dialstr, &sock))
+//    {
+//        int rv = -1;
+//        switch (sock.addr.in.sin_family)
+//        {
+//            case AF_INET:
+//                rv = bind(sock.fd, (struct sockaddr*)&sock.addr.in, sizeof(sock.addr.in));
+//                break;
+//
+//            case AF_UNIX:
+//                if (connect(sock.fd, (struct sockaddr*)&sock.addr.un, sizeof(sock.addr.un)) < 0)
+//                {
+//                    unlink(sock.addr.un.sun_path);
+//                    rv = bind(sock.fd, (struct sockaddr*)&sock.addr.un, sizeof(sock.addr.un));
+//                }
+//                break;