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
I've made normal client server application that uses rust-raknet, but once the first client is accepted by the RaknetListener, the listener stop accepting new connections.
So I made a test program that binds a RaknetListener and accepts clients in a loop and reads data from them and prints it. And i've added loop that connects clients to the listener. This test program also stop accepting new connections after few clients that got accepted. Code below:
letmut server = rust_raknet::RaknetListener::bind(&"0.0.0.0:1337".parse().unwrap()).await.unwrap();
server.listen().await;
log::info!("Listening on {}", server.local_addr().unwrap());
tokio::spawn(asyncmove{loop{
log::info!("Accepting...");let client = server.accept().await.unwrap();
log::info!("Accepted: {}", client.peer_addr().unwrap());
tokio::spawn(asyncmove{loop{let msg = client.recv().await;
log::info!("Received: {:?}", msg);if msg.is_err(){break;// Stop the task}}});}});
tokio::time::sleep(std::time::Duration::from_secs(2)).await;// Wait some time for the server to start accepting connectionsloop{
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
tokio::spawn(asyncmove{
log::info!("Connecting new client...");let client = rust_raknet::RaknetSocket::connect(&"127.0.0.1:1337".parse().unwrap()).await.unwrap();
log::info!("Connected to {}", client.peer_addr().unwrap());
client.send(&[0xFE,0x02,0x03,0x04], rust_raknet::Reliability::ReliableOrdered).await.unwrap();let _ = client.close().await;});}
The text was updated successfully, but these errors were encountered:
I've made normal client server application that uses rust-raknet, but once the first client is accepted by the RaknetListener, the listener stop accepting new connections.
So I made a test program that binds a RaknetListener and accepts clients in a loop and reads data from them and prints it. And i've added loop that connects clients to the listener. This test program also stop accepting new connections after few clients that got accepted. Code below:
The text was updated successfully, but these errors were encountered: