pub fn listen<S: ?Sized + AsRef<str>, H: ConnectionHandler + Send + Sync + 'static>(
handler: H,
address: &S,
initial_worker_threads: usize,
max_worker_threads: usize,
idle_timeout: u64
) -> Result<()>
Expand description
listen
creates a server, with num_worker
threads listening on varlink_uri
.
If an idle_timeout
!= 0 is specified, this function returns after the specified
amount of seconds, if no new connection is made in that time frame. It still waits for
all pending connections to finish.
Examples
extern crate failure;
extern crate varlink;
use failure::Fail;
let service = varlink::VarlinkService::new(
"org.varlink",
"test service",
"0.1",
"http://varlink.org",
vec![/* Your varlink interfaces go here */],
);
if let Err(e) = varlink::listen(service, "unix:/tmp/test_listen_timeout", 1, 10, 1) {
if e.kind() != varlink::ErrorKind::Timeout {
panic!("Error listen: {:?}", e.cause());
}
}
Note
You don’t have to use this simple server. With the VarlinkService::handle()
method you
can implement your own server model using whatever framework you prefer.