#Dioxus UDP backend.

1 messages · Page 1 of 1 (latest)

jovial sphinx
#

I'm trying to get started on a project that uses UDP to send requests to the serverside and recieve "live" updates from the serverside. However when I try to bind a socket to an IP address in the code for a component I get an error saying it's not allowed on this platform. How would I go about this?

#[component]
pub fn App() -> Element {
    let socket = std::net::UdpSocket::bind("127.0.0.1:8080").expect("Failed to bind socket!");
    rsx! {
        button {
            onclick: move |_| test_udp(&socket),
            "BTN"
        }
    }
}
marsh fossil
#

You want to bind to the socket in an async loop inside a use_future

formal creek
#

which platform?

jovial sphinx
#

Web platform.
So I should make sure its a singleton by moving it out of the component? If so where should it be?

formal creek
#

UDP doesn't work on Web