pub fn create_udp_socket(
ip: &String,
port: u16,
callback: fn(arg0: i32, arg1: &UdpMessage),
) -> UniquePtr<FStackUdpSocket>Examples found in repository?
examples/udp_echo.rs (line 41)
29fn main() {
30 // Docker/TAP configuration — swap for FStackConfig::for_bare_metal() on bare metal.
31 let cfg = FStackConfig::for_docker();
32
33 println!("Initializing F-Stack...");
34 init_fstack(&cfg.config_args(), &cfg.eal_args());
35
36 let bind_ip = "0.0.0.0".to_string();
37 let bind_port = 8080u16;
38
39 println!("Creating UDP socket on {}:{}...", bind_ip, bind_port);
40 let socket: UniquePtr<FStackUdpSocket> =
41 create_udp_socket(&bind_ip, bind_port, on_packet);
42
43 unsafe {
44 GLOBAL_SOCKET = Some(&*socket as *const FStackUdpSocket);
45 }
46
47 println!("Starting F-Stack UDP event loop...");
48 run_fstack(&socket);
49}