1
我正在使用Tarpc。我可以連接到Tarpc RPC服務而不使用任何東西,但是使用服務器的地址嗎?
客戶
let (_, mut auth_reactor) = auth::spawn_server(auth_server_address);
let auth_client: auth::FutureClient = auth_reactor
.run(auth::FutureClient::connect(
auth_server_address,
client::Options::default(),
))
.unwrap();
auth_reactor
.run(
auth_client
.authme(byte_vector_auth.clone())
.map_err(|e| println!("{}", e))
.and_then(|i| {
println!("{:?}", i);
Ok(())
}),
)
.unwrap();
服務器
pub fn spawn_server(address: SocketAddr) -> (server::Handle, reactor::Core) {
let reactor = reactor::Core::new().unwrap();
client::Options::default().handle(reactor.handle());
let (auth_handler, server) = AuthServer
.listen(address, &reactor.handle(), server::Options::default())
.unwrap();
reactor.handle().spawn(server);
return (auth_handler, reactor);
}
我返回反應器,因爲我需要它的客戶。