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

This example sends four messages called data portions to the example.com website using a single system call on an orginary TcpStream:

(examples/sender.rs)

#![feature(iovec)]

use sendmmsg::Sendmmsg;
use std::io::IoVec;
use std::net::TcpStream;

fn main() {
    // Specify all the messages you want to send
    let messages = &mut [
        (0, IoVec::new(b"Generals gathered in their masses")),
        (0, IoVec::new(b"Just like witches at black masses")),
        (0, IoVec::new(b"Evil minds that plot destruction")),
        (0, IoVec::new(b"Sorcerers of death's construction")),
    ];

    // 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),
    }
}

More realistic examples are located in the examples directory (and you are able to run them). To investigate the library abstractions, visit the official documentation.


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)