sendmmsg 0.2.0

Transmit multiple messages using one system call in Rust

This crate provides a convenient approach for transmitting multiple messages using one system call (but only on Linux-based operating systems), which will increase performance for large data sets. TCP and UDP protocols are supported.


Usage

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:

[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)

use std::net::TcpStream;
use sendmmsg::{Sendmmsg, DataPortion};

// Specify all the messages you want to send
let messages = &mut [
    DataPortion::with_message(b"Generals gathered in their masses"),
    DataPortion::with_message(b"Just like witches at black masses"),
    DataPortion::with_message(b"Evil minds that plot destruction"),
    DataPortion::with_message(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
match socket.sendmmsg(messages) {
    Err(error) => eprintln!("An error occurred: {}!", error),
    Ok(packets) => println!("Packets sent: {}", packets),
}

Contributing

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.


Contacts

Temirkhan Myrzamadi <gymmasssorla@gmail.com> (the author)