Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (22 sloc) 925 Bytes
// This example sends four messages called data portions to the example.com
// website using a single system call on an orginary TcpStream.
#![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),
}
}
You can’t perform that action at this time.