The original intent of the TCP protocol was to ensure that a connection is established and data is transferred reliably.
However, you should be aware of some adverse effects when transferring log data over TCP.
The reliability-first approach of the TCP protocol creates some overhead on the system since it needs to create a connection and maintain its state, deliver packets in the correct order, ensure data integrity, and resend packages if required.
Even so, it is still possible to lose data if the server prematurely closes the connection while it is transmitting data.
In such cases, unsent data stored in the socket buffers will be lost.
Additionally, even though TCP can detect duplicate packets, there are instances where data duplication is possible.
For example, this can happen if the ACK packets are lost and data is retransmitted.
In other words, although TCP is designed to guarantee that each packet arrives only once, if the connection breaks, there is no way of knowing what exactly arrived.
In most cases, TCP is suitable for transferring logs because its benefits outweigh the disadvantages.
Although TCP cannot guarantee that data loss or duplication will never happen, there are other ways to make your log transfer more reliable, and NXLog can help with this.