First, you need to link the library with your executable (or another library) by putting sendmmsg
to the dependencies section in your Cargo.toml
like this:
toml
[dependencies]
sendmmsg = "*"
Next, just copy this code into your main function and launch the compiled program, which simply sends four packets to the example.com
site:
(examples/minimal.rs
)
```rust
use std::net::TcpStream;
use sendmmsg::{Sendmmsg, DataPortion};
// Specify all the messages you want to send
let messages = &mut [
DataPortion::withmessage(b"Generals gathered in their masses"),
DataPortion::withmessage(b"Just like witches at black masses"),
DataPortion::withmessage(b"Evil minds that plot destruction"),
DataPortion::withmessage(b"Sorcerers of death's construction"),
];
F
// Setup the TcpStream
instance connected to example.com
let socket = TcpStream::connect("93.184.216.34:80").unwrap();
// Finally, send all the messages above unsafe { match socket.sendmmsg(messages) { Err(error) => eprintln!("An error occurred: {}!", error), Ok(packets) => println!("Packets sent: {}", packets), } } ```
You are always welcome for any contribution to this project! But before you start, you should read the appropriate document to know about the preferred development process and the basic communication rules.
Temirkhan Myrzamadi <gymmasssorla@gmail.com> (the author)