Pass can reuse to bind_socket

This commit is contained in:
Yuke Peng
2024-08-24 12:01:08 +08:00
committed by Tate, Hongliang Tian
parent dc4df47007
commit 434f143e30
5 changed files with 21 additions and 9 deletions

View File

@ -30,6 +30,7 @@ impl InitStream {
pub fn bind(
self,
endpoint: &IpEndpoint,
can_reuse: bool,
) -> core::result::Result<AnyBoundSocket, (Error, Self)> {
let unbound_socket = match self {
InitStream::Unbound(unbound_socket) => unbound_socket,
@ -40,7 +41,7 @@ impl InitStream {
));
}
};
let bound_socket = match bind_socket(unbound_socket, endpoint, false) {
let bound_socket = match bind_socket(unbound_socket, endpoint, can_reuse) {
Ok(bound_socket) => bound_socket,
Err((err, unbound_socket)) => return Err((err, InitStream::Unbound(unbound_socket))),
};
@ -52,7 +53,7 @@ impl InitStream {
remote_endpoint: &IpEndpoint,
) -> core::result::Result<AnyBoundSocket, (Error, Self)> {
let endpoint = get_ephemeral_endpoint(remote_endpoint);
self.bind(&endpoint)
self.bind(&endpoint, false)
}
pub fn connect(