https://github.com/njaard/anysocket
Wrap either Tcp or Unix Domain sockets in rust
https://github.com/njaard/anysocket
Last synced: about 2 months ago
JSON representation
Wrap either Tcp or Unix Domain sockets in rust
- Host: GitHub
- URL: https://github.com/njaard/anysocket
- Owner: njaard
- License: bsd-2-clause
- Created: 2020-08-31T21:47:56.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-31T21:48:11.000Z (about 5 years ago)
- Last Synced: 2025-08-02T09:27:52.115Z (2 months ago)
- Language: Rust
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This library exposes new types that wrap _either_
`TcpSocket` or `UnixSocket` types.This library compiles on Windows but doesn't support UnixSocket types.
Before:
```
if addr.starts_with("unix:") {
let socket = UnixListener::bind(&addr["unix:".len() ..]).expect("binding");
while let Ok(socket) = socket.accept() {
// ...
}
}
else {
let socket = TcpListener::bind(addr).expect("binding");;
while let Ok(socket) = socket.accept() {
// ...
}
}
```After:
```
let socket = addr.bind_any().expect("binding");
while let Ok(socket) = socket.accept() {
// ...
}```