EthernetClient - Send string not char

Hi. My first post in here so I hope I posted under the correct section.

Here we go...

If I use the EthernetClient from my Arduino to send a message to a server like this

client.print("Distance is 20");

everything is ok... My server receives to complete string as a byte[]...

But... I want to combine a string with a integer and when I do that the message is sent one char at the time.
So the first thing received is 'D', then "i", then "s" and so on...

How can I build a string myself and still send it so that the whole message arrives at once?

Hope that makes sense.

Regards

This sends it all as one packet.

tBuffer[32];
int distance = 20;

sprintf(tBuffer,"Distance is %u",distance);
client.write(tBuffer);

Solved it by doing

char outBuf[20];   
sprintf(outBuf,"sensor:change:%d\r\n",distance);
client.write(outBuf);

That looks about the same, but if the distance variable is more than 3 characters (>999) when converted into text, that will overflow the outBuf array. :frowning: