|
|
|
#[cfg(feature = "std")]
|
|
|
|
use ironforce::interface::Interface;
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
use ironforce::interfaces::ip::IPInterface;
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
use std::net;
|
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
use ironforce::res::IFResult;
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
fn main() {
|
|
|
|
println!("hello");
|
|
|
|
test();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
fn test() -> IFResult<()> {
|
|
|
|
let message = *b"Hello world from iron forest";
|
|
|
|
|
|
|
|
let mut interface1 = IPInterface::new()?;
|
|
|
|
let mut interface2 = IPInterface::new()?;
|
|
|
|
|
|
|
|
let t1 = std::thread::spawn(move || {
|
|
|
|
interface1.send(&message, Some(String::from("127.0.0.1:50001"))).unwrap();
|
|
|
|
interface1
|
|
|
|
});
|
|
|
|
thread::sleep(Duration::from_millis(10));
|
|
|
|
let t2 = std::thread::spawn(move || {
|
|
|
|
|
|
|
|
interface2.main_loop_iteration().unwrap();
|
|
|
|
interface2
|
|
|
|
});
|
|
|
|
let res1 = t1.join();
|
|
|
|
match res1 {
|
|
|
|
Ok(_) => println!("Ok"),
|
|
|
|
Err(e) => println!("{:?}", e)
|
|
|
|
}
|
|
|
|
let res2 = t2.join();
|
|
|
|
match res2 {
|
|
|
|
Ok(_) => println!("Ok"),
|
|
|
|
Err(e) => println!("{:?}", e)
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
fn main() {}
|