Sock::RecvUntilTerminator

Read from socket until a terminator character is encountered. Will never consume bytes past the terminator from the socket.

Synopsis

Declared in <util/sock.h>

[[nodiscard]]
virtual
std::string
RecvUntilTerminator(
    uint8_t terminator,
    std::chrono::milliseconds timeout,
    CThreadInterrupt& interrupt,
    size_t max_data) const;

Exceptions

NameThrown on
std::runtime_errorif the operation cannot be completed. In this case some bytes may have been consumed from the socket.

Return Value

The data that has been read, without the terminating character.

NOTE

The return value should not be discarded.

Parameters

NameDescription
terminator [in]Character up to which to read from the socket.
timeout [in]Timeout for the entire operation.
interrupt [in]If this is signaled then the operation is canceled.
max_data [in]The maximum amount of data (in bytes) to receive. If this many bytes are received and there is still no terminator, then this method will throw an exception.