// Package netutil holds small TCP tuning helpers shared by the host and // client binaries. package netutil import "net" // SetNoDelay disables Nagle's algorithm on conn if it's a TCP connection. // Nagle coalesces small writes to reduce packet count, which is the right // tradeoff for bulk throughput but actively hurts an interactive protocol // like this one — a mouse-move or a small frame-delta chunk can otherwise // sit buffered for tens of milliseconds waiting for more data before the // kernel sends it. Worth the extra packet overhead here. func SetNoDelay(conn net.Conn) { if tc, ok := conn.(*net.TCPConn); ok { _ = tc.SetNoDelay(true) } }