Use tcpNoDelay option for sockets (#298)

This commit is contained in:
Sigurd Meldgaard 2020-05-11 12:47:15 +02:00 committed by GitHub
parent 03ecb84064
commit 39c751128c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -78,6 +78,8 @@ class Http2ClientConnection implements connection.ClientConnection {
Future<ClientTransportConnection> connectTransport() async {
final securityContext = credentials.securityContext;
Socket socket = await Socket.connect(host, port);
// Don't wait for io buffers to fill up before sending requests.
socket.setOption(SocketOption.tcpNoDelay, true);
if (securityContext != null) {
// Todo(sigurdm): We want to pass supportedProtocols: ['h2']. http://dartbug.com/37950
socket = await SecureSocket.secure(socket,

View File

@ -105,10 +105,17 @@ class Server {
server = _secureServer;
} else {
_insecureServer = await ServerSocket.bind(
address ?? InternetAddress.anyIPv4, port ?? 80, backlog: backlog, shared: shared , v6Only: v6Only);
address ?? InternetAddress.anyIPv4,
port ?? 80,
backlog: backlog,
shared: shared,
v6Only: v6Only,
);
server = _insecureServer;
}
server.listen((socket) {
// Don't wait for io buffers to fill up before sending requests.
socket.setOption(SocketOption.tcpNoDelay, true);
final connection = ServerTransportConnection.viaSocket(socket,
settings: http2ServerSettings);
_connections.add(connection);