From 8475a3aad93e7cdd080acd5d96cf05a929a2868e Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 30 Jul 2023 11:46:53 +0200 Subject: [PATCH] socket-client: Send a user-provided message to the server --- apps/socket-client.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/socket-client.cpp b/apps/socket-client.cpp index 67d2f3d2..9ea4fd29 100644 --- a/apps/socket-client.cpp +++ b/apps/socket-client.cpp @@ -1,11 +1,20 @@ +#include #include #include #include #include #include -int main() +Result 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);