Function varlink::listen[][src]

pub fn listen<S: ?Sized + AsRef<str>>(
    service: VarlinkService,
    address: &S,
    initial_worker_threads: usize,
    accept_timeout: u64
) -> Result<()>

listen creates a server, with num_worker threads listening on varlink_uri.

If an accept_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", 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.