MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SendBytes

Method SendBytes

cpp/src/platform/HttpClient.cpp:746–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744#endif
745
746bool TcpSocket::SendBytes
747(
748const void *str,
749unsigned int len
750)
751{
752 if(!len)
753 return true;
754 if(!SOCKETVALID(_s))
755 return false;
756 //traceprint("SEND: '%s'\n", str);
757
758 unsigned written = 0;
759 while(true) // FIXME: buffer bytes to an internal queue instead?
760 {
761 int ret = _writeBytes((const unsigned char*)str + written, len - written);
762 if(ret > 0)
763 {
764 assert((unsigned)ret <= len);
765 written += (unsigned)ret;
766 if(written >= len)
767 break;
768 }
769 else if(ret < 0)
770 {
771#ifdef _DEBUG
772 int err = ret == -1 ? _GetError() : ret;
773 traceprint("SendBytes: error %d: %s\n", err, _GetErrorStr(err).c_str());
774#endif
775 close();
776 return false;
777 }
778 // and if ret == 0, keep trying.
779 }
780
781 assert(written == len);
782 return true;
783}
784
785int TcpSocket::_writeBytes
786(

Callers

nothing calls this directly

Calls 3

_GetErrorFunction · 0.85
_GetErrorStrFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected