Skip to content

njaard/anysocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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() {
	// ...
}

About

Wrap either Tcp or Unix Domain sockets in rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages