Struct tiny_http::Server
[−]
[src]
pub struct Server { /* fields omitted */ }
The main class of this library.
Destroying this object will immediatly close the listening socket annd the reading
part of all the client's connections. Requests that have already been returned by
the recv()
function will not close and the responses will be transferred to the client.
Methods
impl Server
[src]
fn http<A>(addr: A) -> Result<Server, Box<Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
[src]
A: ToSocketAddrs,
Shortcut for a simple server on a specific address.
fn new<A>(
config: ServerConfig<A>
) -> Result<Server, Box<Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
[src]
config: ServerConfig<A>
) -> Result<Server, Box<Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
Builds a new server that listens on the specified address.
fn incoming_requests(&self) -> IncomingRequests
[src]
Returns an iterator for all the incoming requests.
The iterator will return None
if the server socket is shutdown.
fn server_addr(&self) -> SocketAddr
[src]
Returns the address the server is listening to.
fn num_connections(&self) -> usize
[src]
Returns the number of clients currently connected to the server.
fn recv(&self) -> IoResult<Request>
[src]
Blocks until an HTTP request has been submitted and returns it.
fn recv_timeout(&self, timeout: Duration) -> IoResult<Option<Request>>
[src]
Same as recv()
but doesn't block longer than timeout
fn try_recv(&self) -> IoResult<Option<Request>>
[src]
Same as recv()
but doesn't block.