5 unstable releases
0.3.1 | Jun 22, 2020 |
---|---|
0.3.0 | Jun 21, 2020 |
0.2.0 | Jun 17, 2020 |
0.1.1 | Jun 16, 2020 |
0.1.0 | Jun 16, 2020 |
#123 in #udp
22 downloads per month
22KB
405 lines
aurpc
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
.
Examples
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?;
}
License
This crate is licensed under the MIT license. See the license for more details.
Dependencies
~6–17MB
~193K SLoC