chore(udp): Use SocketRef

This commit is contained in:
Σrebe - Romain GERARD 2023-11-09 17:09:47 +01:00
parent 4f58e42634
commit b55ddd5947
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4

View file

@ -36,7 +36,7 @@ struct UdpServer {
impl UdpServer { impl UdpServer {
pub fn new(listener: UdpSocket, timeout: Option<Duration>) -> Self { pub fn new(listener: UdpSocket, timeout: Option<Duration>) -> Self {
let socket = socket2::Socket::from(listener.into_std().unwrap()); let socket = socket2::SockRef::from(&listener);
// Increase receive buffer // Increase receive buffer
if let Err(err) = socket.set_recv_buffer_size(64 * 1024 * 1024) { if let Err(err) = socket.set_recv_buffer_size(64 * 1024 * 1024) {
@ -48,7 +48,7 @@ impl UdpServer {
} }
Self { Self {
listener: Arc::new(UdpSocket::from_std(socket.into()).unwrap()), listener: Arc::new(listener),
peers: HashMap::with_hasher(ahash::RandomState::new()), peers: HashMap::with_hasher(ahash::RandomState::new()),
keys_to_delete: Default::default(), keys_to_delete: Default::default(),
cnx_timeout: timeout, cnx_timeout: timeout,