https://github.com/narrowlink/uds-stream-windows
Tokio-based Unix Domain Socket (UDS) for Windows with AsyncRead/AsyncWrite support
https://github.com/narrowlink/uds-stream-windows
rust uds windows
Last synced: 3 days ago
JSON representation
Tokio-based Unix Domain Socket (UDS) for Windows with AsyncRead/AsyncWrite support
- Host: GitHub
- URL: https://github.com/narrowlink/uds-stream-windows
- Owner: narrowlink
- License: mit
- Created: 2026-04-27T04:01:27.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-27T04:04:42.000Z (about 2 months ago)
- Last Synced: 2026-05-01T03:07:32.362Z (about 1 month ago)
- Topics: rust, uds, windows
- Language: Rust
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UDS-STREAM-WINDOWS
`uds-stream-windows` is a Rust library that provides a Tokio-compatible Unix Domain Socket (UDS) implementation for Windows, offering `UdsListener` and `UdsStream` types that implement `AsyncRead` and `AsyncWrite`. It leverages the native `AF_UNIX` support introduced in recent Windows versions, making it easy to work with Unix Domain Sockets on Windows just as you would on Unix-like systems.
## FEATURES
* **AsyncRead/AsyncWrite**: `uds-stream-windows` provides `UdsStream` and `UdsListener` that integrate seamlessly with the `tokio` ecosystem, allowing you to use standard `AsyncReadExt` and `AsyncWriteExt` methods.
* **Native Windows Support**: Specifically designed for Windows, utilizing `WSAEventSelect` and registration for asynchronous I/O completion.
* **Simple API**: The API is designed to be familiar to users of `tokio::net::UnixStream` and `tokio::net::UnixListener`.
## USAGE
To use `uds-stream-windows` in your Rust project, add it as a dependency in your `Cargo.toml` file:
```toml
[dependencies]
uds-stream-windows = "0.0.1"
```
Then, you can use it in your Rust code:
### Client Example
```rust
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use uds_stream_windows::UdsStream;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let path = "example.sock";
let mut stream = UdsStream::connect(path).await?;
println!("Connected to {}", path);
let msg = "Hello from the Windows UDS client!";
stream.write_all(msg.as_bytes()).await?;
let mut buf = vec![0u8; 1024];
let n = stream.read(&mut buf).await?;
println!("Received: {}", String::from_utf8_lossy(&buf[..n]));
Ok(())
}
```
### Server Example
```rust
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use uds_stream_windows::UdsListener;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let path = "example.sock";
let listener = UdsListener::bind(path)?;
println!("Server listening on {}", path);
loop {
let (mut stream, addr) = listener.accept().await?;
tokio::spawn(async move {
let mut buf = [0u8; 1024];
if let Ok(n) = stream.read(&mut buf).await {
let _ = stream.write_all(&buf[..n]).await;
}
});
}
}
```
## CONTRIBUTING
Contributions to `uds-stream-windows` are welcome! If you would like to contribute to the library, please follow the standard Rust community guidelines for contributing, including opening issues, submitting pull requests, and providing feedback.
## LICENSE
`uds-stream-windows` is licensed under the MIT License, which allows for free use, modification, and distribution, subject to the terms and conditions outlined in the license.