mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-01-23 09:48:54 +00:00
Add support of TCP_NODELAY option for TCP transport.
Bump version to 2.1.0.
This commit is contained in:
parent
530905f276
commit
c84b8cb143
@ -1,5 +1,5 @@
|
|||||||
packageName = "asyncdispatch2"
|
packageName = "asyncdispatch2"
|
||||||
version = "2.0.9"
|
version = "2.1.0"
|
||||||
author = "Status Research & Development GmbH"
|
author = "Status Research & Development GmbH"
|
||||||
description = "Asyncdispatch2"
|
description = "Asyncdispatch2"
|
||||||
license = "Apache License 2.0 or MIT"
|
license = "Apache License 2.0 or MIT"
|
||||||
|
@ -13,10 +13,14 @@ when defined(windows):
|
|||||||
import winlean
|
import winlean
|
||||||
const
|
const
|
||||||
asyncInvalidSocket* = AsyncFD(-1)
|
asyncInvalidSocket* = AsyncFD(-1)
|
||||||
|
TCP_NODELAY* = 1
|
||||||
|
IPPROTO_TCP* = 6
|
||||||
else:
|
else:
|
||||||
import posix
|
import posix
|
||||||
const
|
const
|
||||||
asyncInvalidSocket* = AsyncFD(posix.INVALID_SOCKET)
|
asyncInvalidSocket* = AsyncFD(posix.INVALID_SOCKET)
|
||||||
|
TCP_NODELAY* = 1
|
||||||
|
IPPROTO_TCP* = 6
|
||||||
|
|
||||||
proc setSocketBlocking*(s: SocketHandle, blocking: bool): bool =
|
proc setSocketBlocking*(s: SocketHandle, blocking: bool): bool =
|
||||||
## Sets blocking mode on socket.
|
## Sets blocking mode on socket.
|
||||||
|
@ -25,7 +25,7 @@ const
|
|||||||
type
|
type
|
||||||
ServerFlags* = enum
|
ServerFlags* = enum
|
||||||
## Server's flags
|
## Server's flags
|
||||||
ReuseAddr, ReusePort, NoAutoRead, GCUserData
|
ReuseAddr, ReusePort, TcpNoDelay, NoAutoRead, GCUserData
|
||||||
|
|
||||||
TransportAddress* = object
|
TransportAddress* = object
|
||||||
## Transport network address
|
## Transport network address
|
||||||
|
@ -853,6 +853,14 @@ proc createStreamServer*(host: TransportAddress,
|
|||||||
serverSocket.closeSocket()
|
serverSocket.closeSocket()
|
||||||
raiseTransportOsError(err)
|
raiseTransportOsError(err)
|
||||||
|
|
||||||
|
if ServerFlags.TcpNoDelay in flags:
|
||||||
|
if not setSockOpt(serverSocket, handles.IPPROTO_TCP,
|
||||||
|
handles.TCP_NODELAY, 1):
|
||||||
|
let err = osLastError()
|
||||||
|
if sock == asyncInvalidSocket:
|
||||||
|
serverSocket.closeSocket()
|
||||||
|
raiseTransportOsError(err)
|
||||||
|
|
||||||
toSockAddr(host.address, host.port, saddr, slen)
|
toSockAddr(host.address, host.port, saddr, slen)
|
||||||
if bindAddr(SocketHandle(serverSocket), cast[ptr SockAddr](addr saddr),
|
if bindAddr(SocketHandle(serverSocket), cast[ptr SockAddr](addr saddr),
|
||||||
slen) != 0:
|
slen) != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user