TCPClient print

Hi

Is is possible to send TCPClient print or println characters at once not sending one by one. Problem is that if Spark sending large amount of POST data to target server, then it takes a several seconds to complete POST request. Sometimes connection is interrupted and some of data is missing of end of POST request. So are there any possibilities to send POST data to server without sending bytes one by one.

Thanks.

Hi @markopraakli

Have you tried using TCPClient.write(buf, len);?

I think that this might work faster for you since you are removing the print layer.

Hi,

Could you provide an example for write String to TCPClient.write.

Thanks

Something like this:

String postString("This is what I want to send");

TCPClient.write(postString.c_str, postString.length);

Warning: I haven’t tested this.

Now i got another conversion error:
error: invalid conversion from ‘const char*’ to 'const uint8_t*

OK, I tested this:

String testString("This is what I want to send");

TCPClient.write( (uint8_t*)testString.c_str(), testString.length() );
TCPClient.println();  //may be needed

Don’t forget that if you had println() before you need to add a CR or LF or both to the end of your String, or just call println() like I did above.