static bool sendBuffer(CotpConnection* self) { int writeBufferPosition = ByteBuffer_getSize(self->writeBuffer); bool retVal = false; if (Socket_write(self->socket, ByteBuffer_getBuffer(self->writeBuffer), writeBufferPosition) == writeBufferPosition) retVal = true; ByteBuffer_setSize(self->writeBuffer, 0); return retVal; }
int ByteStream_sendBuffer(ByteStream self) { int writeBufferPosition = ByteBuffer_getSize(self->writeBuffer); if (Socket_write(self->socket, ByteBuffer_getBuffer(self->writeBuffer), writeBufferPosition) == writeBufferPosition) { ByteBuffer_setSize(self->writeBuffer, 0); return 1; } else return -1; }