Fix support for a Windows client connection for IpcClient
This commit is contained in:
parent
f483184917
commit
b4c4cab666
|
@ -14,3 +14,6 @@ mio-named-pipes = { git = "https://github.com/alexcrichton/mio-named-pipes" }
|
|||
miow = "0.2"
|
||||
log = "*"
|
||||
bytes = "0.4"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winbase"] }
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -214,7 +214,19 @@ impl IpcStream {
|
|||
|
||||
#[cfg(windows)]
|
||||
fn connect_inner(path: &Path, handle: &Handle) -> io::Result<NamedPipe> {
|
||||
NamedPipe::new(&path, &handle)
|
||||
use std::fs::OpenOptions;
|
||||
use std::os::windows::fs::OpenOptionsExt;
|
||||
use std::os::windows::io::{FromRawHandle, IntoRawHandle};
|
||||
use winapi::um::winbase::FILE_FLAG_OVERLAPPED;
|
||||
miow::pipe::NamedPipe::wait(path, None)?;
|
||||
let mut options = OpenOptions::new();
|
||||
options.read(true)
|
||||
.write(true)
|
||||
.custom_flags(FILE_FLAG_OVERLAPPED);
|
||||
let file = options.open(path)?;
|
||||
let mio_pipe = unsafe { mio_named_pipes::NamedPipe::from_raw_handle(file.into_raw_handle()) };
|
||||
let pipe = NamedPipe::from_pipe(mio_pipe, &handle)?;
|
||||
Ok(pipe)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue