The asio
is not compatible to Rust
stable version (ver 1.9). Please install a Rust-nightly
.
This crate is on github and can be used by adding asio
to the dependencies in your project's Cargo.toml
.
toml
[dependencies]
asio = "0.1"
And this in your crate root:
rust
extern crate asio;
For example, Connection with TCP socket code:
```rust use asio::; use asio::ip::;
struct TcpClient(TcpSocket);
impl TcpClient { fn start(io: &IoService) { let soc = Strand::new(io, TcpClient(TcpSocket::new(Tcp::v4()))); let ep = TcpEndpoint::new((IpAddrV4::new(192.168.0.1), 12345)); TcpSocket::asyncconnect(|soc|, &soc.0, &ep, Self::onconnect, &soc); }
fn onconnect(soc: Strand
fn main() { let io = IoService::new(); TcpClient::start(&io); io.run(); } ```
Currently supported platforms: - Linux (kernel in version >=2.6.27)