commit 605dc309306e1f4336f669d146adb22bc91679cc
parent 0f8ace70814d23c4764edce4eb843fd411a31628
Author: Remy Noulin <loader2x@gmail.com>
Date: Wed, 31 Aug 2022 02:02:52 -0400
call recv before closing the socket only when sending data
package.yml | 2 +-
sclient.c | 14 ++++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
Diffstat:
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/package.yml b/package.yml
@@ -1,6 +1,6 @@
---
name: tuyau
- version: 0.0.5
+ version: 0.0.6
description: "Client for copying files to tuyauServer"
bin: ./tuyau.c
#cflags: -DA -g3 -std=gnu11 -fPIC -pipe
diff --git a/sclient.c b/sclient.c
@@ -399,12 +399,14 @@ int main(int ARGC, char** ARGV) {
// release SSL state
SSL_free(ssl);
SSL_CTX_free(ssl_ctx);
- // some data needs to be received in order to send all data to the server, SSL_write says all the data is sent but it is not true, why?
- // 478 bytes are received. It seems to be encrypted.
- // SSL_shutdown() and shutdown() don't help
- int r = recv(sock, buf, sizeof(buf), 0);
- if (r == -1) {
- logE("recv before closing the socket");
+ if (!isReceive) {
+ // some data needs to be received in order to send all data to the server, SSL_write says all the data is sent but it is not true, why?
+ // 478 bytes are received. It seems to be encrypted.
+ // SSL_shutdown() and shutdown() don't help
+ int r = recv(sock, buf, sizeof(buf), 0);
+ if (r == -1) {
+ logE("recv before closing the socket");
+ }
}
close(sock);
}