src/vs/platform/remote/common/remoteAgentConnection.ts/createSocket
function createSocket(logService: ILogService, socketFactory: ISocketFactory, host: string, port: number, query: string, timeoutCancellationToken: CancellationToken): Promise<ISocket> {
	const result = new PromiseWithTimeout<ISocket>(timeoutCancellationToken);
	socketFactory.connect(host, port, query, (err: any, socket: ISocket | undefined) => {
		if (result.didTimeout) {
			if (err) {
				logService.error(err);
			}
			socket?.dispose();
		} else {
			if (err || !socket) {
				result.reject(err);
			} else {
				result.resolve(socket);
			}
		}
	});
	return result.promise;
}