From a962c8af92327e9b8b91ae71c21f5e7bdf6f117d Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Fri, 27 Mar 2009 13:29:46 +0000 Subject: [PATCH] Adding a test for fd passing capability. --- tests/socket.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/socket.c diff --git a/tests/socket.c b/tests/socket.c new file mode 100644 index 0000000..b1c4371 --- /dev/null +++ b/tests/socket.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + + +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"); + +} + -- 2.43.0