项目作者: NikVolf

项目描述 :
Parity tokio-ipc
高级语言: Rust
项目地址: git://github.com/NikVolf/parity-tokio-ipc.git
创建时间: 2017-03-14T15:54:20Z
项目社区:https://github.com/NikVolf/parity-tokio-ipc

开源协议:Other

下载


parity-tokio-ipc

CI
Documentation

This crate abstracts interprocess transport for UNIX/Windows.

It utilizes unix sockets on UNIX (via tokio::net::UnixStream) and named pipes on windows (via tokio::net::windows::named_pipe module).

Endpoint is transport-agnostic interface for incoming connections:

  1. use parity_tokio_ipc::Endpoint;
  2. use futures::stream::StreamExt;
  3. // For testing purposes only - instead, use a path to an actual socket or a pipe
  4. let addr = parity_tokio_ipc::dummy_endpoint();
  5. let server = async move {
  6. Endpoint::new(addr)
  7. .incoming()
  8. .expect("Couldn't set up server")
  9. .for_each(|conn| async {
  10. match conn {
  11. Ok(stream) => println!("Got connection!"),
  12. Err(e) => eprintln!("Error when receiving connection: {:?}", e),
  13. }
  14. });
  15. };
  16. let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
  17. rt.block_on(server);

License

parity-tokio-ipc is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0), with portions covered by various
BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.