Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
fix async example
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstp committed May 6, 2019
1 parent cb41499 commit 1599007
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ extern crate igd;
extern crate futures;
extern crate tokio_core;

use std::env;
use std::net::SocketAddrV4;

use igd::async::search_gateway;
use igd::PortMappingProtocol;
use futures::future::Future;

fn main() {
let ip = match env::args().nth(1) {
Some(ip) => ip,
None => {
println!("Local socket address is missing!");
println!("This example requires a socket address representing the local machine and the port to bind to as an argument");
println!("Example: target/debug/examples/async 192.168.0.198:4321");
println!("Example: cargo run --features async --example async -- 192.168.0.198:4321");
return;
}
};
let ip: SocketAddrV4 = ip.parse().expect("Invalid socket address");

let mut evloop = tokio_core::reactor::Core::new().unwrap();
let handle = evloop.handle();

Expand All @@ -34,7 +49,7 @@ fn main() {
gateway.add_port(
PortMappingProtocol::TCP,
1234,
"192.168.1.210:4321".parse().unwrap(),
ip,
0,
"rust-igd-async-example",
)
Expand All @@ -48,7 +63,7 @@ fn main() {
gateway.add_port(
PortMappingProtocol::TCP,
2345,
"192.168.1.210:5432".parse().unwrap(),
ip,
0,
"rust-igd-async-example",
)
Expand Down

0 comments on commit 1599007

Please sign in to comment.