Mbed 5 issue in send data through ethernet to PuTTY console using TCPSocket[int socket].send(string)

I am running mbed-OS-5 on a NUCLEO-STM32F767ZI based board.
We communicate to the board through an ethernet connection using PuTTY.
I am wanting to print out information to the PuTTY console, however much of the data does not get printed out. It seems that the print statements that execute, i.e. output data to the PuTTY console, varies with each run, where everytime I run, the missing data varies (missing print statements varies).

I am using the following 2 statements to perform printing:

  •        sprintf(Auto_Response, "N:  n =<%i>\r\n", n);
  •       client_sock[socket].send(Auto_Response, strlen(Auto_Response));

where we declared:

  •       TCPSocket  client_sock[2];
  •       char[64]  AutoResponse;

I am wondering if I can add a pause after the 2nd statement (the client_sock) statement, if that would allow enough time for the data to output to the PuTTY console, because perhaps the program is running too fast, that those output statements don’t have enough time to execute.

Does this assessment sound correct? i.e. need like a pause statement to allow the “client_sock” statement to execute and send that string to the PuTTY console?

Do I need to change the blocking mode from false to true?

  •        client_sock[socket].set_blocking(false);

If you are continuously reusing the AutoResponse buffer without checking if all data has already been transmitted then yes you should use blocking mode.
When doing a blocking send the call will not return until all characters are send and the buffer can safely be reused.
Without blocking, the call will return immediately and the content of the buffer will be transmitted at some later time. Thus it is not safe to reuse the buffer until you have determined that all characters have been actually send.