dns_resolver::util::net

Function read_tcp_bytes

Source
pub async fn read_tcp_bytes(
    stream: &mut TcpStream,
) -> Result<BytesMut, TcpError>
Expand description

Read a DNS message from a TCP stream.

A DNS TCP message is slightly different to a DNS UDP message: it has a big-endian u16 prefix giving the total length of the message. This is redundant (since the header is fixed-size and says how many fields there are, and the fields contain length information), but it means the entire message can be read before parsing begins.

ยงErrors

If reading from the stream fails or returns an incomplete message.