Adding a test for fd passing capability.
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 27 Mar 2009 13:29:46 +0000 (13:29 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 27 Mar 2009 13:29:46 +0000 (13:29 +0000)
tests/socket.c [new file with mode: 0644]

diff --git a/tests/socket.c b/tests/socket.c
new file mode 100644 (file)
index 0000000..b1c4371
--- /dev/null
@@ -0,0 +1,35 @@
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int
+main(int argc, char *argv[])
+{
+    int sfd;
+    struct sockaddr_un addr;
+
+    sfd = socket(AF_UNIX, SOCK_STREAM, 0);
+    if (sfd == -1) {
+        perror("socket");
+        exit(EXIT_FAILURE);
+    }
+
+    memset(&addr, 0, sizeof(struct sockaddr_un));
+    /* Clear structure */
+    addr.sun_family = AF_UNIX;
+    strncpy(addr.sun_path, argv[1],
+            sizeof(addr.sun_path) - 1);
+
+    if (connect(sfd, (struct sockaddr *) &addr,
+                sizeof(struct sockaddr_un)) == -1) {
+        perror("bind");
+        exit(EXIT_FAILURE);
+    }
+
+    printf("Connected\n");
+
+}
+