Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By Chris--A
#15330 Use WifiClient.write( buffer, length ); where possible!!

.write( buff, len ) sends a buffer using tcp_write().

.print/ln() eventually call .write() with a single character, which basically means, 1 character per tcp_write() call.

Calling .write() with a large buffer directly should dramatically improve performance especially if tcp_write() is blocking while a packet is sent.

This is not a bug, but more of a consequence of using a library meant for generalized communication. WifiClient inherits Client which inherits Stream which inherits Print. It is a virtual nightmare for efficiency, but it works!

Calling .write() allows you to call the most derived implementation directly.
User avatar
By martinayotte
#15416 I understand the efficiency differences between .write() and .print() and all those Stream/Print I/Os, so I've changed my code to used .write() instead. But still, the issue I means here, why we have 150ms latency for every packet sent.
Like I've mentionned in another thread, IPAddress.printTo() is taking 1 sec to print.
So yes, I've worked around it by adding IPAddress.toCharArray() and then sending it as a single print().
The problem still, especially in a TCP2Serial scenario, or even for those who wish to send files over TCP, this kind latency is simply not acceptable. Currently, my TCP2Serial prototype, which inputs at 115200Kb, look more like a 9600bps on the TCP side. :(