summaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-06-02 22:07:50 +0200
committerOskar <[email protected]>2024-06-02 22:07:50 +0200
commit4333fba71bbdadfe078aa7ebbe9194c6fc35af22 (patch)
treeb64b746a7ca4fadced5203f426a11af4f347bd9b /client.c
parent4d60b8da9cdcd4716fe65c8872ec60a14d2c1e48 (diff)
improved bytes recieved calculation
Diffstat (limited to 'client.c')
-rw-r--r--client.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/client.c b/client.c
index 9be43ae..d0ef45f 100644
--- a/client.c
+++ b/client.c
@@ -17,6 +17,9 @@
#define __PORT "62000"
#define BUF_SZ_2 2048
+int sockfd = -1;
+size_t bytes_sent = 0;
+
void talk_to_server (int sockfd) {
while (1) {
@@ -29,19 +32,13 @@ void talk_to_server (int sockfd) {
continue;
}
- if (editbuffer[0] == '\n') {
- send(sockfd, editbuffer, fgs_len, 0);
- continue;
- } else {
- send(sockfd, editbuffer, fgs_len, 0);
- continue;
- }
+ bytes_sent = bytes_sent + send(sockfd, editbuffer, fgs_len, 0);
}
}
-void INThandler(int sockfd) {
+void INThandler() {
- fprintf(stderr, "\n");
+ fprintf(stderr, "\nbytes sent: %ld\n", bytes_sent);
close(sockfd);
exit(0);
}
@@ -53,7 +50,6 @@ int main (int argc, char *argv[]) {
exit(__FAIL);
}
- int sockfd = -1;
int gai_result;
int connect_result = -1;
struct addrinfo hints;