Skip to content

Commit

Permalink
update socket2
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 15, 2021
1 parent 295286d commit 099d7d4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ntex/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* framed: refactor api

* update socket2 0.4

## [0.3.8] - 2021-03-11

* http: fix expect/continue support, wake up write task
Expand Down
2 changes: 1 addition & 1 deletion ntex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ slab = "0.4"
serde = { version = "1.0", features=["derive"] }
serde_json = "1.0"
serde_urlencoded = "0.7"
socket2 = "0.3"
socket2 = "0.4"
url = "2.1"
coo-kie = { version = "0.15", package = "cookie", optional = true }
time = { version = "0.2", default-features = false, features = ["std"] }
Expand Down
6 changes: 3 additions & 3 deletions ntex/src/server/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ pub(crate) fn create_tcp_listener(
backlog: i32,
) -> io::Result<net::TcpListener> {
let builder = match addr {
net::SocketAddr::V4(_) => Socket::new(Domain::ipv4(), Type::stream(), None)?,
net::SocketAddr::V6(_) => Socket::new(Domain::ipv6(), Type::stream(), None)?,
net::SocketAddr::V4(_) => Socket::new(Domain::IPV4, Type::STREAM, None)?,
net::SocketAddr::V6(_) => Socket::new(Domain::IPV6, Type::STREAM, None)?,
};

// On Windows, this allows rebinding sockets which are actively in use,
Expand All @@ -513,7 +513,7 @@ pub(crate) fn create_tcp_listener(

builder.bind(&SockAddr::from(addr))?;
builder.listen(backlog)?;
Ok(builder.into_tcp_listener())
Ok(net::TcpListener::from(builder))
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions ntex/src/server/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ mod tests {
assert_eq!(format!("{}", addr), "127.0.0.1:8080");

let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap();
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
socket.set_reuse_address(true).unwrap();
socket.bind(&SockAddr::from(addr)).unwrap();
let tcp = socket.into_tcp_listener();
let tcp = net::TcpListener::from(socket);
let lst = Listener::Tcp(mio::net::TcpListener::from_std(tcp));
assert!(format!("{:?}", lst).contains("TcpListener"));
assert!(format!("{}", lst).contains("127.0.0.1"));
Expand Down
4 changes: 2 additions & 2 deletions ntex/src/server/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ impl TestServer {
/// Get first available unused address
pub fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap();
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
socket.set_reuse_address(true).unwrap();
socket.bind(&SockAddr::from(addr)).unwrap();
let tcp = socket.into_tcp_listener();
let tcp = net::TcpListener::from(socket);
tcp.local_addr().unwrap()
}
}
Expand Down

0 comments on commit 099d7d4

Please sign in to comment.