Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
/ cancellable-io Public archive

Cancellable synchronous network I/O.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Emm54321/cancellable-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cancellable-io

A crate implementing cancellable synchronous network I/O.

This crate exposes structs TcpStream, TcpListener and UdpSocket that are similar to their std::net variants, except that I/O operations can be cancelled through Canceller objects created with them.

Most methods work as they do in the std::net implementations, and you should refer to the original documentation for details and examples.

Main differences with the original std::net implementations :

Example

use cancellable_io::*;
let (listener, canceller) = TcpListener::bind("127.0.0.1:0").unwrap();
let handle = std::thread::spawn(move || {
    println!("Waiting for connections.");
    let r = listener.accept();
    assert!(is_cancelled(&r.unwrap_err()));
    println!("Server cancelled.");
});

std::thread::sleep(std::time::Duration::from_secs(2));
canceller.cancel().unwrap();
handle.join().unwrap();

License: MIT/Apache-2.0

About

Cancellable synchronous network I/O.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages