diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index bc1b7ff4..2a2289b2 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c @@ -155,16 +155,16 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) return -1; - increment_nonce(con->sent_nonce); - len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); - if ((unsigned int)len == sizeof(packet)) - return 1; - if (len <= 0) return 0; + increment_nonce(con->sent_nonce); + + if ((unsigned int)len == sizeof(packet)) + return 1; + memcpy(con->last_packet, packet, length); con->last_packet_length = sizeof(packet); con->last_packet_sent = len; diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 7487ad4f..6c0133dd 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -335,16 +335,16 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) return -1; - increment_nonce(con->sent_nonce); - len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); - if ((unsigned int)len == sizeof(packet)) - return 1; - if (len <= 0) return 0; + increment_nonce(con->sent_nonce); + + if ((unsigned int)len == sizeof(packet)) + return 1; + memcpy(con->last_packet, packet, length); con->last_packet_length = sizeof(packet); con->last_packet_sent = len;