Search code examples
erlanggen-tcp

Erlang gen_tcp delaying send


I have the below code as part of an Erlang web server for many long-lived concurrent connections.

SockOpts = [
    binary,
    {active, false},
    {packet, http_bin},
    {reuseaddr, true},
    {packet_size, 16384},
    {recbuf, 16384},
    {backlog, 100},

    {delay_send, false},
    {nodelay, true}
],
gen_tcp:listen(Port, SockOpts)

Despite me adding the delay_send and nodelay options, it seems to be buffering data, so that small pieces of data aren't sent until either a bigger chunk of data's sent or the server's killed. Why is this, and how can I force it to send all data immediately?


Solution

  • Turns out it was NSURLConnection in the iPad client buffering the data, and not passing it on immediately.

    I switched to CFNetwork, which is fun.