summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorIgor Matuszewski <Xanewok@gmail.com>2020-03-13 23:32:07 +0100
committerIgor Matuszewski <igor@sequoia-pgp.org>2020-03-18 17:52:38 +0100
commit1c759995eaf46f3d587d231a954142b341f666be (patch)
tree8f523f1df5e9aed230b4e9a736b28d11bac97b41 /ipc
parent6c9ea4e1543d54100cbf74f0d9a970bcb93494dc (diff)
ipc: Prefer Ipv4Addr::LOCALHOST over a string
Diffstat (limited to 'ipc')
-rw-r--r--ipc/src/lib.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/ipc/src/lib.rs b/ipc/src/lib.rs
index 364a58b0..0c90b933 100644
--- a/ipc/src/lib.rs
+++ b/ipc/src/lib.rs
@@ -38,7 +38,7 @@
use std::fs;
use std::io::{self, Read, Write};
-use std::net::{SocketAddr, AddrParseError, TcpStream, TcpListener};
+use std::net::{Ipv4Addr, SocketAddr, AddrParseError, TcpStream, TcpListener};
use std::path::PathBuf;
extern crate capnp_rpc;
@@ -103,8 +103,6 @@ pub struct Descriptor {
factory: HandlerFactory,
}
-const LOCALHOST: &str = "127.0.0.1";
-
impl Descriptor {
/// Create a descriptor given its rendezvous point, the path to
/// the servers executable file, and a handler factory.
@@ -221,7 +219,7 @@ impl Descriptor {
/* Write connection information to file. */
file.set_len(0)?;
cookie.send(&mut file)?;
- write!(file, "{}:{}", LOCALHOST, addr.port())?;
+ write!(file, "{}", addr)?;
}
drop(file);
@@ -234,7 +232,7 @@ impl Descriptor {
/// Start the service, either as an external process or as a
/// thread.
fn start(&self, external: bool) -> Result<SocketAddr> {
- let listener = TcpListener::bind((LOCALHOST, 0)).unwrap();
+ let listener = TcpListener::bind((Ipv4Addr::LOCALHOST, 0)).unwrap();
let addr = listener.local_addr()?;
/* Start the server, connect to it, and send the cookie. */