According to the documentation endTransmission does not return the number of bytes sent, rather it returns a non zero number if there is an error.
The documentation is here:...