summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-06-02 16:09:00 +0200
committerOskar <[email protected]>2024-06-02 16:09:00 +0200
commitcc2deeaefb53f5a40122f6cda31168021abcd139 (patch)
tree774b9b886c97692ec93cda000aa36f46bd346d14
parent8b80185d9db97a5e8e93f763a4c190183317f44f (diff)
client
-rw-r--r--Makefile2
-rw-r--r--client.c33
2 files changed, 28 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index ca64efa..8615444 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
CC=gcc
CFLAGS_TESTBIN=-Og -fsanitize=address -Wfatal-errors -Wall -Werror -Werror=return-type -Wextra -g -Wpedantic -std=gnu99
-CFLAGS=-O3 -flto -march=native -DNDEBUG -fomit-frame-pointer -s -std=gnu99
+CFLAGS=-O3 -flto -march=native -DNDEBUG -fomit-frame-pointer -std=gnu99
MAKEFLAGS += -j$(nproc)
TARGETS=helloworld
TARGETS2=binding
diff --git a/client.c b/client.c
index e023465..2b0488f 100644
--- a/client.c
+++ b/client.c
@@ -15,6 +15,30 @@
#define __FAIL EXIT_FAILURE
#define BACKLOG 2
#define __PORT "62000"
+#define BUF_SZ_2 2048
+
+int talk_to_server (int sockfd) {
+
+ while (1) {
+ char editbuffer[BUF_SZ_2];
+ fprintf(stdout, ": ");
+
+ char *fgs = fgets(editbuffer, BUF_SZ_2, stdin);
+ socklen_t fgs_len = strlen(editbuffer);
+ if (fgs == NULL) {
+ return 0;
+ }
+
+ if (editbuffer[0] == '\n') {
+ send(sockfd, editbuffer, fgs_len, 0);
+ continue;
+ } else {
+ send(sockfd, editbuffer, fgs_len, 0);
+ continue;
+ }
+ }
+ return 0;
+}
int main () {
@@ -55,13 +79,10 @@ int main () {
}
- char *msg = "Client says hello!\n";
- size_t len = strlen(msg);
+ //char *msg = "Client says hello!\n";
+ //size_t len = strlen(msg);
- for (int i = 0 ; i < 10 ; i++) {
-
- send(sockfd, msg, len, 0);
- }
+ talk_to_server(sockfd);
freeaddrinfo(res);
return 0;
}