Skip to content
✉️ Transmit multiple messages using one system call in Rust
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
examples
src
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.toml
ICON.png
LICENSE
README.md
rustfmt.toml

README.md

sendmmsg


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.

Pulse · Stargazers · Releases · Contributing


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)

You can’t perform that action at this time.