فهرست منبع

example/rpc: Add unix listeners.

parazyd 3 سال پیش
والد
کامیت
9103045723
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 2 1
      example/rpc/client.rs
  2. 2 1
      example/rpc/server.rs

+ 2 - 1
example/rpc/client.rs

@@ -26,7 +26,8 @@ use darkfi::{
 };
 };
 
 
 async fn realmain(ex: Arc<Executor<'_>>) -> Result<()> {
 async fn realmain(ex: Arc<Executor<'_>>) -> Result<()> {
-    let endpoint = Url::parse("tcp://127.0.0.1:55422").unwrap();
+    //let endpoint = Url::parse("tcp://127.0.0.1:55422").unwrap();
+    let endpoint = Url::parse("unix:///tmp/rpc.sock").unwrap();
 
 
     let client = RpcClient::new(endpoint, Some(ex)).await?;
     let client = RpcClient::new(endpoint, Some(ex)).await?;
 
 

+ 2 - 1
example/rpc/server.rs

@@ -66,7 +66,8 @@ impl RequestHandler for RpcSrv {
 
 
 async fn realmain(ex: Arc<Executor<'_>>) -> Result<()> {
 async fn realmain(ex: Arc<Executor<'_>>) -> Result<()> {
     let rpcsrv = Arc::new(RpcSrv { stop_sub: smol::channel::unbounded::<()>() });
     let rpcsrv = Arc::new(RpcSrv { stop_sub: smol::channel::unbounded::<()>() });
-    let rpc_listen = Url::parse("tcp://127.0.0.1:55422").unwrap();
+    //let rpc_listen = Url::parse("tcp://127.0.0.1:55422").unwrap();
+    let rpc_listen = Url::parse("unix:///tmp/rpc.sock").unwrap();
 
 
     let _ex = ex.clone();
     let _ex = ex.clone();
     ex.spawn(listen_and_serve(rpc_listen, rpcsrv.clone(), _ex)).detach();
     ex.spawn(listen_and_serve(rpc_listen, rpcsrv.clone(), _ex)).detach();