apps: Add socket-test

This commit is contained in:
apio 2023-07-27 16:37:17 +02:00
parent a12b018b03
commit 9303c44269
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 25 additions and 0 deletions

View File

@ -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)

24
apps/socket-test.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
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;
}
}