Get bytes to send on the wire, if any, along with other information about it.

Synopsis

Declared in <net.h>

virtual
BytesToSend
GetBytesToSend(bool have_next_message) const noexcept = 0;

Description

As a const function, it does not modify the transport's observable state, and is thus safe to be called multiple times.

Effectively, there are three possible outcomes about whether there are more bytes to send:

  • Yes: the transport itself has more bytes to send later. For example, for V1Transport this happens during the sending of the header of a message, when there is a non‐empty payload that follows.

  • No: the transport itself has no more bytes to send, but will have bytes to send if handed a message through SetMessageToSend. In V1Transport this happens when sending the payload of a message.

  • Blocked: the transport itself has no more bytes to send, and is also incapable of sending anything more at all now, if it were handed another message to send. This occurs in V2Transport before the handshake is complete, as the encryption ciphers are not set up for sending messages before that point.

The boolean 'more' is true for Yes, false for Blocked, and have_next_message controls what is returned for No.

Return Value

a BytesToSend object. The to_send member returned acts as a stream which is only ever appended to. This means that with the exception of MarkBytesSent (which pops bytes off the front of later to_sends), operations on the transport can only append to what is being returned. Also note that m_type and to_send refer to data that is internal to the transport, and calling any non‐const function on this object may invalidate them.

Parameters

Name

Description

have_next_message [in]

If true, the "more" return value reports whether more will be sendable after a SetMessageToSend call. It is set by the caller when they know they have another message ready to send, and only care about what happens after that. The have_next_message argument only affects this "more" return value and nothing else.

Created with MrDocs