Closed ghmlee closed 9 years ago
Sure - it's pretty straightforward. You open a UnixStream
with the connect
method which is passed the path to the unix socket file on the filesystem:
let mut socket = try!(UnixStream::connect("/run/postgres/.s.PGSQL.5432");
UnixStream
implements Read
and Write
, so you can use it like any other stream:
let mut buf = vec![];
try!(socket.read_to_end(&mut buf));
@sfackler Thank you so much. :)
Recently I found std::old_io::net::pipe::UnixStream will be deprecated and also some people mentioned your unix_socket. If you are not busy (of course you are busy), may I ask you to show me UnixStream example? Thanks. :)