Tcp-Handler
Read this in other languages: English, 简体中文.
Description
More conveniently use tokio::net::TcpStream
to transfer bytes::Bytes
data chunks.
You may use extra crate to read and write data, such as serde, postcard and variable-len-reader.
See tcp-server and tcp-client for conveniently building your tcp application.
Features
- Based on tokio and bytes.
- Support
ReadHalf
andWriteHalf
oftokio::net::TcpStream
. (In fact anything implAsyncRead
/AsyncWrite
andUnpin
can be used.) - Support
bytes::Buf
. So you can send discontinuous data chunks by callingchain
. - Support encryption (rsa and aes).
- Support compression (flate2).
- Complete API document and data model.
Usage
Add this to your Cargo.toml
:
[]
= "^1.0"
Note
If client_init
using encryption mode is extremely slow in debug mode,
please add this to your Cargo.toml
in client side:
[]
= 3 # Speed up rsa key gen.
This is an issue in rsa crate.
Example
With TcpHandler
, you can use all the protocols in a similar way.
use ;
use ;
use *;
use ;
use ;
use ;
async
Protocol Version
The protocol version code used internally. Note only when the server and client sides have the same code, they can connect normally.
crate version | protocol version |
---|---|
>=0.6.0 | 1 |
<0.6.0 | 0 |
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.