set_nodelay
fn set_nodelay(Stream s, bool enabled) -> Result<unit, IoError> Import
Source: use io::net::tcp::{set_nodelay}; compiler/src/builtin_docs/io/net/tcp.hy Turns TCP_NODELAY on or off for a TCP stream.
With enabled == true small writes are sent at once instead of being
held back to be combined (Nagle’s algorithm). Works on streams that a
package such as coil-tls has attached to, since they share the socket.
Returns Err(IoError::InvalidInput) for a listener or a stream that is
not TCP.
Parameters#
| Name | Type |
|---|---|
s | Stream |
enabled | bool |
Returns#
Result<unit, IoError>
Examples#
use io::{IoError};
use io::net::tcp::{connect, listen, local_addr, set_nodelay};
use tests::assert;
fn run() -> Result<unit, IoError> {
let listener = listen("127.0.0.1", 0)?;
let (_, port) = local_addr(listener)?;
let client = connect("127.0.0.1", port)?;
set_nodelay(client, true)?;
return ();
}
fn main() {
let ok = match run() {
Result::Ok(_) => true,
Result::Err(_) => false,
};
assert!(ok);
}
See also#
accept: Accepts one pending connection onlistenerwithout waiting.connect: Opens a TCP connection tohostonport.connect_timeout: Opens a TCP connection tohostonport, giving up aftermsmilliseconds.listen: Opens a TCP socket listening onhostandport.local_addr: Returns the local(host, port)of a TCP listener or connected TCP stream.peer_addr: Returns the remote(host, port)of a connected TCP stream.shutdown: Shuts down the reading half, the writing half, or both halves of a TCP stream.