pub struct TcpBind {
pub host: String,
pub port: u16,
}Available on crate features
tcp-binder and server only.Expand description
The TCP server binder.
This ServerBinder uses the TCP protocol to bind a listener, to
read requests and write responses.
Fields§
§host: StringThe TCP host of the listener.
port: u16The TCP port of the listener.
Implementations§
Trait Implementations§
source§impl ServerBind for TcpBind
impl ServerBind for TcpBind
source§fn bind(&self, timer: ThreadSafeTimer) -> Result<()>
fn bind(&self, timer: ThreadSafeTimer) -> Result<()>
Bind the TCP listener.
To bind, the TcpBind gets a std::net::TcpListener then
indefinitely waits for incoming requests. When a connection
comes, TcpBind retrieves the associated
std::net::TcpStream and send it to the helper
crate::ServerStream::handle.
source§impl ServerStream<TcpStream> for TcpBind
impl ServerStream<TcpStream> for TcpBind
source§fn read(&self, stream: &TcpStream) -> Result<Request>
fn read(&self, stream: &TcpStream) -> Result<Request>
Read the given std::net::TcpStream to extract the request
sent by the client.
source§fn write(&self, stream: &mut TcpStream, res: Response) -> Result<()>
fn write(&self, stream: &mut TcpStream, res: Response) -> Result<()>
Write the given response to the given std::net::TcpStream.
fn handle(&self, timer: ThreadSafeTimer, stream: &mut T) -> Result<()>
Auto Trait Implementations§
impl RefUnwindSafe for TcpBind
impl Send for TcpBind
impl Sync for TcpBind
impl Unpin for TcpBind
impl UnwindSafe for TcpBind
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more