chore: wip

This commit is contained in:
2025-03-01 11:04:03 +01:00
parent 43232b4317
commit db964493c2
3 changed files with 7 additions and 13 deletions
+1
View File
@@ -10,4 +10,5 @@ RUN make
FROM scratch FROM scratch
COPY --from=builder /opt/builder/build/qotd / COPY --from=builder /opt/builder/build/qotd /
COPY quotes.txt / COPY quotes.txt /
STOPSIGNAL SIGKILL
ENTRYPOINT ["/qotd"] ENTRYPOINT ["/qotd"]
+5 -12
View File
@@ -8,9 +8,6 @@
#include <unistd.h> // read(), write(), close() #include <unistd.h> // read(), write(), close()
#include <errno.h> #include <errno.h>
#include "config.h" #include "config.h"
#define MAX 80
#define PORT 17
#define SA struct sockaddr
int main() int main()
{ {
@@ -23,17 +20,15 @@ int main()
if (sockfd == -1) if (sockfd == -1)
{ {
printf("socket creation failed...\n"); printf("socket creation failed...\n");
exit(0); exit(1);
} }
else
printf("Socket successfully created..\n");
// assign IP, PORT // assign IP, PORT
servaddr4.sin_family = AF_INET; servaddr4.sin_family = AF_INET;
servaddr4.sin_addr.s_addr = inet_addr("127.0.0.1"); servaddr4.sin_addr.s_addr = inet_addr("127.0.0.1");
servaddr4.sin_port = htons(PORT); servaddr4.sin_port = htons(DEFAULT_LISTEN_PORT);
int status = connect(sockfd, (SA *)&servaddr4, sizeof servaddr4); int status = connect(sockfd, (struct sockaddr *)&servaddr4, sizeof servaddr4);
// connect the client socket to server socket // connect the client socket to server socket
if (status != 0) if (status != 0)
{ {
@@ -42,15 +37,13 @@ int main()
exit(0); exit(0);
} }
else
printf("connected to the server..\n");
struct sockaddr *servaddr = (SA *)&servaddr4; struct sockaddr *servaddr = (struct sockaddr *)&servaddr4;
unsigned int ss = sizeof servaddr; unsigned int ss = sizeof servaddr;
// function for chat // function for chat
char clientMessage[MESSAGE_STRING_LENGTH] = {0}; char clientMessage[MESSAGE_STRING_LENGTH] = {0};
recvfrom(sockfd, clientMessage, MESSAGE_STRING_LENGTH, 0, servaddr, &ss); recvfrom(sockfd, clientMessage, MESSAGE_STRING_LENGTH, 0, servaddr, &ss);
printf(clientMessage); puts(clientMessage);
// close the socket // close the socket
close(sockfd); close(sockfd);
+1 -1
View File
@@ -1 +1 @@
première ligne \n Deuxième ligne première ligne \n Deuxième ligne \n troixième ligne