Learn R Programming

gtools (version 3.9.5)

setTCPNoDelay: Modify the TCP_NODELAY (`de-Nagle') flag for socket objects

Description

Modify the TCP_NODELAY (`de-Nagle') flag for socket objects

Usage

setTCPNoDelay(socket, value = TRUE)

Value

The character string "SUCCESS" will be returned invisible if the operation was successful. On failure, an error will be generated.

Arguments

socket

A socket connection object

value

Logical indicating whether to set (TRUE) or unset (FALSE) the flag

Author

Gregory R. Warnes greg@warnes.net

Details

By default, TCP connections wait a small fixed interval before actually sending data, in order to permit small packets to be combined. This algorithm is named after its inventor, John Nagle, and is often referred to as 'Nagling'.

While this reduces network resource utilization in these situations, it imposes a delay on all outgoing message data, which can cause problems in client/server situations.

This function allows this feature to be disabled (de-Nagling, value=TRUE) or enabled (Nagling, value=FALSE) for the specified socket.

References

"Nagle's algorithm" https://en.wikipedia.org/wiki/Nagle's_algorithm,

Nagle, John. "Congestion Control in IP/TCP Internetworks", IETF Request for Comments 896, January 1984. https://www.ietf.org/rfc/rfc0896.txt?number=896

See Also

Examples

Run this code
if (FALSE) {
host <- "www.r-project.org"
socket <- make.socket(host, 80)
print(socket)
setTCPNoDelay(socket, TRUE)

write.socket(socket, "GET /\n\n")
write.socket(socket, "A")
write.socket(socket, "B\n")
while ((str <- read.socket(socket)) > "") {
  cat(str)
}
close.socket(socket)
}

Run the code above in your browser using DataLab