aboutsummaryrefslogtreecommitdiff
path: root/examples/std/src/bin/net_dns.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-02-10 23:00:16 +0100
committerDario Nieuwenhuis <[email protected]>2023-02-10 23:00:16 +0100
commita509af4bc00ae6945e568b268731e854e8ae3994 (patch)
treebae6c5aced02342b257fccafdc601c8046b3ad50 /examples/std/src/bin/net_dns.rs
parenta2b8921ff3e0b50da824c2242f0b90f9f8f9a0e2 (diff)
exmaples/dns: don't use the socket.
Diffstat (limited to 'examples/std/src/bin/net_dns.rs')
-rw-r--r--examples/std/src/bin/net_dns.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/std/src/bin/net_dns.rs b/examples/std/src/bin/net_dns.rs
index e787cb823..e1cc45a38 100644
--- a/examples/std/src/bin/net_dns.rs
+++ b/examples/std/src/bin/net_dns.rs
@@ -4,7 +4,7 @@ use std::default::Default;
4 4
5use clap::Parser; 5use clap::Parser;
6use embassy_executor::{Executor, Spawner}; 6use embassy_executor::{Executor, Spawner};
7use embassy_net::dns::{DnsQueryType, DnsSocket}; 7use embassy_net::dns::DnsQueryType;
8use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources}; 8use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
9use heapless::Vec; 9use heapless::Vec;
10use log::*; 10use log::*;
@@ -65,17 +65,14 @@ async fn main_task(spawner: Spawner) {
65 let seed = u64::from_le_bytes(seed); 65 let seed = u64::from_le_bytes(seed);
66 66
67 // Init network stack 67 // Init network stack
68 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<2>::new()), seed)); 68 let stack: &Stack<_> = &*singleton!(Stack::new(device, config, singleton!(StackResources::<2>::new()), seed));
69 69
70 // Launch network task 70 // Launch network task
71 spawner.spawn(net_task(stack)).unwrap(); 71 spawner.spawn(net_task(stack)).unwrap();
72 72
73 // Then we can use it!
74 let socket = DnsSocket::new(stack);
75
76 let host = "example.com"; 73 let host = "example.com";
77 info!("querying host {:?}...", host); 74 info!("querying host {:?}...", host);
78 match socket.query(host, DnsQueryType::A).await { 75 match stack.dns_query(host, DnsQueryType::A).await {
79 Ok(r) => { 76 Ok(r) => {
80 info!("query response: {:?}", r); 77 info!("query response: {:?}", r);
81 } 78 }