This is a test using Markdown language !
Here's a code sample to create an UDP socket, written in rust
!
use std::net::UdpSocket;
fn main() -> std::io::Result<()> {
{
let socket = UdpSocket::bind("127.0.0.1:34254")?;
// Receives a single datagram message on the socket. If `buf` is too small to hold
// the message, it will be cut off.
let mut buf = [0; 10];
let (amt, src) = socket.recv_from(&mut buf)?;
// Redeclare `buf` as slice of the received data and send reverse data back to origin.
let buf = &mut buf[..amt];
buf.reverse();
socket.send_to(buf, &src)?;
} // the socket is closed here
Ok(())
}
Syntax | Description | Test Text |
---|---|---|
Header | Title | Here's this |
Paragraph | Text | And more |