diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 20d24f19..a892f745 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -42,3 +42,4 @@ luna_app(cp.cpp cp) luna_app(kill.cpp kill) luna_app(gol.cpp gol) luna_app(buffer-test.cpp buffer-test) +luna_app(socket-test.cpp socket-test) diff --git a/apps/socket-test.cpp b/apps/socket-test.cpp new file mode 100644 index 00000000..3907ec3c --- /dev/null +++ b/apps/socket-test.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +int main() +{ + int sockfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockfd < 0) + { + perror("socket"); + return 0; + } + + struct sockaddr_un un; + un.sun_family = AF_UNIX; + strncpy(un.sun_path, "/tmp/local.sock", sizeof(un.sun_path)); + + if (bind(sockfd, (struct sockaddr*)&un, sizeof(un)) < 0) + { + perror("bind"); + return 1; + } +}