fn mqtt_server_addr() -> SocketAddrV4 {
    use std::str::FromStr;
    use trust_dns_client::client::{Client, SyncClient};
    use trust_dns_client::op::DnsResponse;
    use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
    use trust_dns_client::udp::UdpClientConnection;

    let address = "1.1.1.1:53".parse().unwrap();
    let conn = UdpClientConnection::new(address).unwrap();
    let client = SyncClient::new(conn);
    let name = Name::from_str("broker.hivemq.com.").unwrap();
    let response: DnsResponse = client.query(&name, DNSClass::IN, RecordType::A).unwrap();
    let answers: &[Record] = response.answers();

    if let Some(&RData::A(ref ip)) = answers[0].data() {
        // this conversion occurs because there are no core networking types
        // see: https://github.com/rust-lang/rfcs/pull/2832
        SocketAddrV4::new(
            Ipv4Addr::new(
                ip.octets()[0],
                ip.octets()[1],
                ip.octets()[2],
                ip.octets()[3],
            ),
            1883,
        )
    } else {
        panic!("unexpected result for DNS query");
    }
}
// we are going to cheat and use a real DNS crate for this lookup
// see the DNS example for how you would acomplish somthing similar with the
// W5500
we are going to cheat and use a real DNS crate for this lookup
see the DNS example for how you would acomplish somthing similar with the
W5500
we are going to cheat and use a real DNS crate for this lookup see the DNS example for how you would acomplish somthing similar with the W5500
fn mqtt_server_addr() -> SocketAddrV4 {
    use std::str::FromStr;
    use trust_dns_client::client::{Client, SyncClient};
    use trust_dns_client::op::DnsResponse;
    use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
    use trust_dns_client::udp::UdpClientConnection;
    let address = "1.1.1.1:53".parse().unwrap();
    let conn = UdpClientConnection::new(address).unwrap();
    let client = SyncClient::new(conn);
    let name = Name::from_str("broker.hivemq.com.").unwrap();
    let response: DnsResponse = client.query(&name, DNSClass::IN, RecordType::A).unwrap();
    let answers: &[Record] = response.answers();
    if let Some(&RData::A(ref ip)) = answers[0].data() {
        // this conversion occurs because there are no core networking types
        // see: https://github.com/rust-lang/rfcs/pull/2832
        SocketAddrV4::new(
            Ipv4Addr::new(
                ip.octets()[0],
                ip.octets()[1],
                ip.octets()[2],
                ip.octets()[3],
            ),
            1883,
        )
    } else {
        panic!("unexpected result for DNS query");
    }
}
fn mqtt_server_addr ( ) -> SocketAddrV4 { use std :: str :: FromStr ; use trust_dns_client :: client :: { Client , SyncClient } ; use trust_dns_client :: op :: DnsResponse ; use trust_dns_client :: rr :: { DNSClass , Name , RData , Record , RecordType } ; use trust_dns_client :: udp :: UdpClientConnection ; let address = " " . parse ( ) . unwrap ( ) ; let conn = UdpClientConnection :: new ( address ) . unwrap ( ) ; let client = SyncClient :: new ( conn ) ; let name = Name :: from_str ( " " ) . unwrap ( ) ; let response : DnsResponse = client . query ( & name , DNSClass :: IN , RecordType :: A ) . unwrap ( ) ; let answers : & [ Record ] = response . answers ( ) ; if let Some ( & RData :: A ( ref ip ) ) = answers [ 0 ] . data ( ) { // this conversion occurs because there are no core networking types // see: https://github.com/rust-lang/rfcs/pull/2832 SocketAddrV4 :: new ( Ipv4Addr :: new ( ip . octets ( ) [ 0 ] , ip . octets ( ) [ 1 ] , ip . octets ( ) [ 2 ] , ip . octets ( ) [ 3 ] , ) , 1883 , ) } else { panic ! ( " " ) ; } }
we are going to cheat and use a real DNS crate for this lookup
see the DNS example for how you would acomplish somthing similar with the
W5500
we are going to cheat and use a real DNS crate for this lookup see the DNS example for how you would acomplish somthing similar with the W5500