Skip to content

Commit

Permalink
disable Nagle's algorithm (fixes #346)
Browse files Browse the repository at this point in the history
  • Loading branch information
ademar committed Dec 8, 2015
1 parent f7348ac commit a37f7ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Suave.LibUv/Native.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type uv_walk_cb = delegate of IntPtr * IntPtr -> unit
[<DllImport("libuv.dll", CallingConvention = CallingConvention.Cdecl)>]
extern int uv_tcp_init(IntPtr loop, IntPtr handle)

[<DllImport("libuv.dll", CallingConvention = CallingConvention.Cdecl)>]
extern int uv_tcp_nodelay(IntPtr handle, int enable)

[<DllImport("libuv.dll", CallingConvention = CallingConvention.Cdecl)>]
extern int uv_ip4_addr(string ip, int port, [<Out>] sockaddr_in& address)

Expand Down
1 change: 1 addition & 0 deletions src/Suave.LibUv/Tcp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ type LibUvServer(maxConcurrentOps, bufferManager, logger : Logger,
this.initLoop()
try
uv_tcp_init(loop, server) |> checkStatus
uv_tcp_nodelay(server, 1) |> checkStatus
uv_ip4_addr(ip, port, &addr) |> checkStatus
uv_tcp_bind(server, &addr, 0) |> checkStatus
let s = new LibUvSocket(opsPool, logger, serveClient, binding, loop,
Expand Down
2 changes: 2 additions & 0 deletions src/Suave/Tcp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ let runServer logger maxConcurrentOps bufferSize (binding: SocketBinding) startD
let a, b, c, bufferManager = createPools logger maxConcurrentOps bufferSize

let listenSocket = new Socket(binding.endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
listenSocket.NoDelay <- true;

aFewTimes (fun () -> listenSocket.Bind binding.endpoint)
listenSocket.Listen MaxBacklog

Expand Down

0 comments on commit a37f7ea

Please sign in to comment.