feat: Add connect timeout to TimeoutSettings (#158)

Because TcpSocket connects in Socket::new TimeoutSettings are now
required for Socket::new. Since we already have TimeoutSettings there
Sockets are now expected to apply timeout settings in Socket::new.
This commit is contained in:
Tom 2023-11-22 10:40:22 +00:00 committed by GitHub
parent 7416d54b14
commit e3bdbc2a41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 97 additions and 42 deletions

View file

@ -32,12 +32,11 @@ pub(crate) struct Unreal2Protocol {
impl Unreal2Protocol {
pub fn new(address: &SocketAddr, timeout_settings: Option<TimeoutSettings>) -> GDResult<Self> {
let socket = UdpSocket::new(address)?;
let socket = UdpSocket::new(address, &timeout_settings)?;
let retry_count = timeout_settings
.as_ref()
.map(|t| t.get_retries())
.unwrap_or_else(|| TimeoutSettings::default().get_retries());
socket.apply_timeout(&timeout_settings)?;
Ok(Self {
socket,