Difference between client.print() and .write()

What’s the difference between client.print() and client.write() to the server?

the descriptions are in the documentation here:
http://docs.spark.io/firmware/#tcpclient-write

basically, print() will print ascii characters while write() will send data as bytes

2 Likes

In addition to what @eely22 said, there is currently a performance penalty in using TCPClient.print() (on both Spark and Arduino by the way). That performance issue is being tracked on github.

The best way to get high performance right now is to get all your data in an array and then do something like:

TCPClient.write(arrayOfBytes, lengthOfArray); 
3 Likes

Thank @bko @eely22 for pointing these out. I was thinking writing to a buffer would be a better way to communicate to a server than sending serial characters.