Skip to content

Commit

Permalink
Set TCP_NODELAY on both client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Dec 9, 2024
1 parent ca32de0 commit 04d095c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ impl Client {
}?;
stream.set_read_timeout(self.timeout)?;
stream.set_write_timeout(self.timeout)?;
stream.set_nodelay(true)?;
Ok(stream)
}

Expand Down
3 changes: 3 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ impl Server {
continue;
}
};
if let Err(error) = stream.set_nodelay(true) {
eprintln!("OxHTTP TCP error when attempting to set the TCP_NODELAY option: {error}");
}
let thread_name = format!("{}: responding thread of OxHTTP", peer_addr);
let thread_guard = thread_limit.as_ref().map(|s| s.lock());
let on_request = Arc::clone(&on_request);
Expand Down

0 comments on commit 04d095c

Please sign in to comment.