Skip to content

Commit

Permalink
refactor(udp): define const for receive buffer size (#1709)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden authored Mar 5, 2024
1 parent d56e993 commit 1ec476e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion neqo-common/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ use tokio::io::Interest;

use crate::{Datagram, IpTos};

/// Socket receive buffer size.
///
/// Allows reading multiple datagrams in a single [`Socket::recv`] call.
const RECV_BUF_SIZE: usize = u16::MAX as usize;

pub struct Socket {
socket: tokio::net::UdpSocket,
state: UdpSocketState,
Expand All @@ -32,7 +37,7 @@ impl Socket {
Ok(Self {
state: quinn_udp::UdpSocketState::new((&socket).into())?,
socket: tokio::net::UdpSocket::from_std(socket)?,
recv_buf: vec![0; u16::MAX as usize],
recv_buf: vec![0; RECV_BUF_SIZE],
})
}

Expand Down

0 comments on commit 1ec476e

Please sign in to comment.