Add Unix domain sockets for local IPC #37

Merged
apio merged 16 commits from unix-sockets into main 2023-07-30 09:49:38 +00:00
Showing only changes of commit 8475a3aad9 - Show all commits

View File

@ -1,11 +1,20 @@
#include <os/ArgumentParser.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
int main()
Result<int> luna_main(int argc, char** argv)
{
StringView message;
os::ArgumentParser parser;
parser.add_description("A UNIX domain socket client, to test said sockets.");
parser.add_system_program_info("socket-client"_sv);
parser.add_positional_argument(message, "message"_sv, "exit"_sv);
parser.parse(argc, argv);
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0)
{
@ -31,8 +40,7 @@ int main()
printf("Message from server: %s\n", buf);
}
const char* message = "EXIT";
write(sockfd, message, strlen(message));
write(sockfd, message.chars(), message.length());
close(sockfd);