Fixed duplicate port bindings

This commit is contained in:
Dennis Schwerdel 2019-12-19 16:13:03 +01:00
parent 714d8c3220
commit f6a72e4174
2 changed files with 2 additions and 7 deletions

View File

@ -12,6 +12,7 @@ This project follows [semantic versioning](http://semver.org).
- [fixed] Added parameter keepalive to manpage
- [fixed] Fixed problems on stats file when dropping permissions
- [fixed] Deleting files before overwriting them
- [fixed] Fixed duplicate port bindings
### v1.1.0 (2019-12-04)

View File

@ -22,19 +22,13 @@ pub trait Socket: AsRawFd + Sized {
impl Socket for UdpSocket {
fn listen_v4(host: &str, port: u16) -> Result<Self, io::Error> {
UdpBuilder::new_v4()
.expect("Failed to obtain ipv4 socket builder")
.reuse_address(true)
.expect("Failed to set so_reuseaddr")
.bind((host, port))
UdpBuilder::new_v4().expect("Failed to obtain ipv4 socket builder").bind((host, port))
}
fn listen_v6(host: &str, port: u16) -> Result<Self, io::Error> {
UdpBuilder::new_v6()
.expect("Failed to obtain ipv4 socket builder")
.only_v6(true)
.expect("Failed to set only_v6")
.reuse_address(true)
.expect("Failed to set so_reuseaddr")
.bind((host, port))
}
fn receive(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr), io::Error> {