sendmmsg 0.1.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.


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:

sendmmsg = "*"

Next, just copy this code into your main function and launch the compiled program, which simply sends four packets to the site:


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"),
// Setup the `TcpStream` instance connected to
let socket = TcpStream::connect("").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 <> (the author)