Struct resolve::socket::DnsSocket
[−]
[src]
pub struct DnsSocket { // some fields omitted }
Represents a socket transmitting DNS messages.
Methods
impl DnsSocket
fn new() -> Result<DnsSocket>
Returns a DnsSocket
, bound to an unspecified address.
fn bind<A: ToSocketAddrs>(addr: A) -> Result<DnsSocket>
Returns a DnsSocket
, bound to the given address.
fn get(&self) -> &UdpSocket
Returns a reference to the wrapped UdpSocket
.
fn send_message<A: ToSocketAddrs>(&self, message: &Message, addr: A) -> Result<(), Error>
Sends a message to the given address.
fn recv_from<'buf>(&self, buf: &'buf mut [u8]) -> Result<(Message<'buf>, SocketAddr), Error>
Receives a message, returning the address of the sender. The given buffer is used to store and parse message data.
The buffer should be exactly MESSAGE_LIMIT
bytes in length.
fn recv_message<'buf>(&self, addr: &SocketAddr, buf: &'buf mut [u8]) -> Result<Option<Message<'buf>>, Error>
Attempts to read a DNS message. The message will only be decoded if the
remote address matches addr
. If a packet is received from a non-matching
address, the message is not decoded and Ok(None)
is returned.
The buffer should be exactly MESSAGE_LIMIT
bytes in length.