Crates.io | aurpc |
lib.rs | aurpc |
version | 0.3.1 |
source | src |
created_at | 2020-06-16 20:32:50.746511 |
updated_at | 2020-06-22 23:25:50.834655 |
description | Asynchronous UDP RPCs |
homepage | |
repository | https://git.ureeves.com/ureeves/aurpc |
max_upload_size | |
id | 254674 |
size | 38,355 |
Asynchronous UDP RPCs.
Exposes a socket-like interface allowing for sending requests and awaiting a response as well as listening to requests, with UDP as transport.
This is achieved by implementing an 24-bit protocol header on top of UDP containing 8-bit flags and a 16-bit request id.
1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags | Request Id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Since a UDP datagram can carry a maximum of 65507 data bytes. This means
that, with the added overhead, each message can be a maximum of 65504 bytes
.
use aurpc::RpcSocket;
let socket = RpcSocket::bind("127.0.0.1:8080").await?;
let mut buf = vec![0u8; 1024];
loop {
let (n, responder) = socket.recv_from(&mut buf).await?;
responder.respond(&buf[..n]).await?;
}
This crate is licensed under the MIT license. See the license for more details.