9 releases

✓ Uses Rust 2018 edition

0.3.6 Jun 28, 2019
0.3.5 Jun 5, 2019
0.3.4 Apr 25, 2019
0.2.0 Apr 12, 2019
0.1.0 Apr 12, 2019

#45 in #udp

Download history 88/week @ 2019-04-15 122/week @ 2019-04-22 87/week @ 2019-04-29 35/week @ 2019-05-06 27/week @ 2019-05-13 35/week @ 2019-05-20 40/week @ 2019-05-27 106/week @ 2019-06-03 106/week @ 2019-06-10 53/week @ 2019-06-17 124/week @ 2019-06-24 60/week @ 2019-07-01 28/week @ 2019-07-08 1/week @ 2019-07-15 10/week @ 2019-07-22

278 downloads per month

MIT license

23KB
89 lines

DEPRECATED SINCE 28-06-2019: this is an incomplete wrapper, and you'd better use https://docs.rs/libc/0.2.58/libc/fn.sendmmsg.html for now. Also support for nix is coming soon.

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)

use std::net::TcpStream;

use sendmmsg::SendMMsg;

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

    // 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(portions) => println!("Portions sent: {}", portions),
    }
}

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)

Dependencies