You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The runtime exposes functions to allow us to set SO_REUSEADDR and SO_REUSEPORT, however it's not working:
wasmer run --net examples/rust_udp/target/wasm32-wasmer-wasi/debug/udp_example.rustc.wasm
Starting UDP server
Binding to 0.0.0.0:8080
Error: Os { code: 3, kind: AddrInUse, message: "Address in use" }
The example code:
use tokio::net::UdpSocket;use std::io;use std::net::{SocketAddr};use socket2::{Socket,Domain,Type};#[tokio::main]asyncfnmain() -> io::Result<()>{println!("Starting UDP server");let std_sock = Socket::new(Domain::IPV4,Type::DGRAM,None)?;
std_sock.set_reuse_address(true)?;println!("Binding to 0.0.0.0:8080");let address:SocketAddr = "0.0.0.0:8080".parse().unwrap();let address = address.into();
std_sock.bind(&address)?;println!("Binding to 0.0.0.0:8080");let sock = UdpSocket::from_std(std_sock.into())?;letmut buf = [0;1024];loop{let(len, addr) = sock.recv_from(&mut buf).await?;println!("{:?} bytes received from {:?}", len, addr);let len = sock.send_to(&buf[..len], addr).await?;println!("{:?} bytes sent", len);}}
Libraries in use (cargo.toml):
[package]
name = "udp_example"
version = "0.1.0"
edition = "2021"
[dependencies]
socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "master" }
tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.35.1", version = "=1.35.1", features = ["fs", "io-util", "io-std","net", "rt", "signal", "macros", "rt", "rt-multi-thread", "signal", "sync", "time", "socket2" ] }
Steps to reproduce
Compile the application and try to open two instances of it using wasmer.
Expected behavior
Actual behavior
It shows an error:
Starting UDP server
Binding to 0.0.0.0:8080
Error: Os { code: 3, kind: AddrInUse, message: "Address in use" }
Describe the bug
The runtime exposes functions to allow us to set SO_REUSEADDR and SO_REUSEPORT, however it's not working:
wasmer run --net examples/rust_udp/target/wasm32-wasmer-wasi/debug/udp_example.rustc.wasm Starting UDP server Binding to 0.0.0.0:8080 Error: Os { code: 3, kind: AddrInUse, message: "Address in use" }
The example code:
Libraries in use (cargo.toml):
Steps to reproduce
Compile the application and try to open two instances of it using wasmer.
Expected behavior
Actual behavior
It shows an error:
Additional context
Journal report:
The text was updated successfully, but these errors were encountered: