getConnectionSocket method
Implementation
Future<Socket> getConnectionSocket({Duration? duration}) async {
var _tmpSocket = await Socket.connect(_ip, _port,
timeout: duration ?? const Duration(seconds: 60));
if (_tmpSocket.address.type != InternetAddressType.unix) {
_tmpSocket.setOption(SocketOption.tcpNoDelay, true);
}
if (credentials.isSecure) {
// Todo(sigurdm): We want to pass supportedProtocols: ['h2'].
// http://dartbug.com/37950
return await SecureSocket.secure(
_tmpSocket,
host: credentials.authority ?? _ip,
context: credentials.securityContext,
onBadCertificate: (cert) {
if (credentials.onBadCertificate != null) {
return credentials.onBadCertificate!(
cert,
credentials.authority ?? _ip,
);
}
return false;
},
);
}
return _tmpSocket;
}