pub struct TcpServer<C>where
C: Encoder<Bytes, Error = Error> + Decoder<Item = BytesMut, Error = Error> + Send + Sync + Clone + 'static + TfCodec,{ /* private fields */ }Expand description
Base binary tcp server.
‘C’ is you codec, that you want to use to encode/decode data.
Recommended default codec is LengthDelimitedCodec, from the server codec module.
Implementations§
Source§impl<C> TcpServer<C>
impl<C> TcpServer<C>
Sourcepub async fn new(
bind_address: String,
router: Arc<TcpServerRouter<C>>,
processor: Option<TrafficProcessorHolder<C>>,
codec: C,
config: Option<ServerConfig>,
) -> Self
pub async fn new( bind_address: String, router: Arc<TcpServerRouter<C>>, processor: Option<TrafficProcessorHolder<C>>, codec: C, config: Option<ServerConfig>, ) -> Self
Creates a new instance of a server.
‘bind_address’ is a target address to bind current server. E.g: 0.0.0.0:8080 ‘router’ setted up router with handlers. Must be called commit_routes before using. ‘processor’ Custom traffic processor, used for all streams. ‘codec’ basically codec used for every stream with it’s own instance, when the codec is applied to stream, first call is clone, the second call is initial_setup. ‘config’ optional config for tls connection, when None the tls is not using, when some all connections are passed behind tls.
Sourcepub async fn start(&mut self) -> JoinHandle<()>
pub async fn start(&mut self) -> JoinHandle<()>
Start the task for handling connections.
Return the join handle, of this task.