Can anyone explain this behavior I am seeing? Using the WiFi library I am seeing the following.
Code example 1 (where client is an instance if WiFiClient):
client.print("Some text: ");
client.println(" some more text");
Code example 2
String var = "Some text: " + String(someInt)+ " some more text");
The first example works very efficiently across the wire and all of the text gets concatenated and sent in a single packet (or two). However the second code example runs very poorly. I have some code that is a little more complex than the above example and when written in the style of the first example makes it to the server in 2 packets. However when written in the style of the second, it sends it in about 6 to 7 packets with a 2 second delay between many of the packets. And in addition, some of the packets only contained one or two characters of text. Its very odd to me. I was hoping to use the second style to create the body of a post (JSON) and make it easy to calculate the content length. But it was so bad I had to go back to other style.
Any ideas about what is going on here?