socket-client: Send a user-provided message to the server
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-07-30 11:46:53 +02:00
parent 187f0ff83e
commit 8475a3aad9
Signed by: apio
GPG Key ID: B8A7D06E42258954

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