diff options
author | Oskar <[email protected]> | 2024-06-02 22:07:50 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-06-02 22:07:50 +0200 |
commit | 4333fba71bbdadfe078aa7ebbe9194c6fc35af22 (patch) | |
tree | b64b746a7ca4fadced5203f426a11af4f347bd9b /client.c | |
parent | 4d60b8da9cdcd4716fe65c8872ec60a14d2c1e48 (diff) |
improved bytes recieved calculation
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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; |