RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-283400

Григорий's questions

Martin Hope
Григорий
Asked: 2022-01-08 16:08:00 +0000 UTC

Chrome:“由于其中一个站点或其中一个应用程序中的数据泄露......”

  • 2

从前端我js将数据发送到后端php:

async registerAsync(login: string, password: string): Promise<void> {
    const resp = await fetch(`php-api/users/register?lg=${login}&ps=${password}`)

    if (resp.status > 400) {
      switch (resp.status) {
        case 504: throw new Error("DB is offline")
        default: throw new Error(resp.statusText)
      }
    }

    localStorage.setItem("user", login)
  }

在后端,我成功接受了参数(此外,我通过POST请求尝试了它):

//// GET: api/register?lg=...&ps=...
  public function RegisterAction() {
    try {
      $login = $this->requestParams["lg"];
      $password = $this->requestParams["ps"];

      $result = $this->repo->Register($login, $password);
      return $this->response("OK");
    } catch (Throwable $th) {
      return $this->response($th->getMessage());
    }
  }

作为响应,php控制器发送一个代码200和一个消息。OK

在此处输入图像描述

我无法摆脱据称我的该网站密码已在 Google Chrome 中泄露的消息:此外,即使我在 Firefox 中完成此注册程序,然后尝试使用此数据进入 Chrome,该消息仍会出现。

在此处输入图像描述

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-01-12 15:48:35 +0000 UTC

为什么先创建附加字段Section_Id、EF、Code?

  • 0

我创建了一个类部分

public class Section
{
    public int Id { get; set; }

    [Required]
    public string Name { get; set; }

    public string ChiefId { get; set; }
    public virtual ApplicationUser Chief { get; set; }

    public virtual ICollection<ApplicationUser> Staff { get; set; }
}

有一个标准类 ApplicationUser

public class ApplicationUser : IdentityUser
{
    public string Name { get; set; }
    public string Surname { get; set; }

    public int? SectionId { get; set; }
    [ForeignKey("SectionId")] <<<<<<<<<< добавлено, но не помогает
    public virtual Section Section { get; set; }


    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Обратите внимание, что authenticationType должен совпадать с типом, определенным в CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Здесь добавьте утверждения пользователя
        return userIdentity;
    }
}

我添加上下文

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public virtual DbSet<Section> Sections { get; set; }
    * * *

为什么在数据库中创建了一个带有空值的附加字段Section_Id(图中显示了一个键的创建 - 一个注释掉的值)?

在此处输入图像描述

并且当它从数据库中删除时,控制器中会抛出异常

在此处输入图像描述

有没有办法摆脱这个额外的领域?

c#
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-12-22 00:42:09 +0000 UTC

多个复选框 MVC

  • 1

需要在一个表单上选择多本书

楷模

public class Book
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Author { get; set; }
    public int Price { get; set; }
    public bool Selected { get; set; }
}

public class Purchase
{
    public int PurchaseId { get; set; }
    public string Person { get; set; }
    public string Address { get; set; }
    public List<Book> Books { get; set; }
}

public class DbInitializer : DropCreateDatabaseAlways<BookContext>
{
    protected override void Seed(BookContext context)
    {
        context.Books.Add(new Book { Name = "Война и мир", Author = "Л.Н. Толстой", Price = 220 });
        context.Books.Add(new Book { Name = "Отцы и дети", Author = "И. Тургенев", Price = 180 });
        context.Books.Add(new Book { Name = "Чайка", Author = "А. Чехов", Price = 150 });

        base.Seed(context);
    }
}

控制器

public class HomeController : Controller
{
    BookContext db = new BookContext();


    [HttpGet]
    public ActionResult Buy()
    {
        return View(db.Books);
    }

    [HttpPost]
    public ActionResult Result(Purchase purchase)
    {
        purchase = purchase; // <<<<<<<<< Here I get Books field == null  <<<<<<<<<<<<<<<<<<
        return View();
    }
}

看法

最后,Buy 方法的视图:

@using HtmlHelpers.Models;
@model IEnumerable<Book>

@using (Html.BeginForm("Result", "Home", FormMethod.Post))
{
    <div class="col-md-6">
        <h2>Book purchasing</h2>

        <table class="table">
            @foreach (var item in Model)
            {
                <tr>
                    <td>@item.Id</td>
                    <td>@item.Name</td>
                    <td>@item.Author</td>
                    <td>@item.Price</td>
                    <td>
                        @Html.CheckBoxFor(c => item.Selected)
                        @Html.HiddenFor(c => item.Id)
                        @Html.HiddenFor(c => item.Name)
                        @Html.HiddenFor(c => item.Author)
                        @Html.HiddenFor(c => item.Price)
                    </td>
                </tr>
            }
        </table>
        <input class="form-control" name="Person" placeholder="Name" />
        <input class="form-control" name="Address" placeholder="Address" />
        <input type="submit" class="btn btn-success" name="Submit" />
    </div>
}

我最终没有在购买实例中获得选定书籍的列表。怎么了?

全部的

c#
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-12-01 12:33:54 +0000 UTC

始终加载 IntelliSense 索引

  • 0

下载 nuget.org 的 IntelliSense 索引

我注意到,当 Win Forms .Net 框架项目启动时,所有后台任务都顺利完成并完成,而一个则一直在运行。

C#

尝试在设置中检查 NuGet 下载包的路径。好的。

在此处输入图像描述

有互联网连接。软件包被一一下载。在哪里查看和配置什么,以便最终执行此服务而不是碍眼?

Visual Studio 社区 2019

c#
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-06-30 17:05:22 +0000 UTC

如何指定包含的dll的位置

  • 0

如何将包含的 .dll 移动到不同的目录?

要使用 MySQL 数据库,您需要一个库,我将其包含在项目链接中:

在此处输入图像描述

结果,在编译时,我得到了一个.exe文件,并且这个库与.exe文件位于同一目录中:

在此处输入图像描述

如何在创建时强制 Visual Studio 将此库放在另一个目录中,比如\Config,它将与创建的.exe文件位于同一目录中?如果此.dll被删除,则应用程序根本拒绝启动。

找到了我的问题的答案,这里仅适用于C#。在C++ cli中哪里可以找到这些设置?

c++-cli
  • 2 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-06-08 14:53:19 +0000 UTC

MS SQL 服务器在哪里运行?

  • 0

我试图了解在 ASP.NET 中与 SQL 的通信是如何工作的

在 Visual Studio 的选项卡中,我发现一个选项卡显示我的计算机上安装了 MS SQL Server,尽管我没有安装它:

在此处输入图像描述 我无法连接到它。我究竟做错了什么?有人可以回答我的问题吗:

  1. Visual Studio 是否仅适用于 MS SQL?(为了在.php上开发站点,我安装了Open Server,它已经包含了MySql。我可以连接到这个数据库并使用它,还是需要单独安装MS SQL)?
  2. Windows 在系统安装期间是否已经安装了 MS SQL 服务器?或者是 Visual Studio 创建了这个服务器(在屏幕截图中)?
  3. 是否有某个地方的指南,或者更确切地说是一个视频,从(安装),配置 MS SQL 服务器到将其连接到 Visual Studio 和使用数据库,一步一步地描述了所有内容?(我发现的所有视频都使用并连接到已安装和配置的 MS SQL Server)..
c#
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-04-15 01:24:05 +0000 UTC

如何将类对象写入文件?

  • 0

如何对 I/O 进行编程?(最好是二进制形式)


using namespace System;
using namespace System::IO;

ref class test {
    String ^value1;
    String ^value2;
    int id;
    String ^value3;
public:
    test() { };
    test(String ^v1, String ^v2, String ^v3, int n) : value1(v1), value2(v2), value3(v3), id(n) { };

    int get_id() { return id; }
    void write_me(String ^path) {
    //.......... <<<< here
    }
    void read_me(String ^path) {
    //.......... <<<< here    
    }
};

int main() {
    test ^tst1("hello","cat", "biscuit", 3);
    tst1->write_me("write_test.dat");

    test ^tst2;
    tst2.read_me("write_test.dat");

    return 0;
}
c++-cli
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-04-12 00:01:00 +0000 UTC

C++ 托管内存数组初始化

  • 0

抽象类.h:

#pragma once
#include "class_word.h"
using namespace System;


ref class notion abstract {
protected:
    String ^ _language;
    String ^ _inscription;
    String ^ _meaning;
    int _id;

public:
    notion(String ^ lng, String ^ inscr, String ^ mnng) :
        _language(lng), _inscription(inscr), _meaning(mnng) { }

    virtual int print() abstract;
};

//---------------------------------------------------------------------
ref class vocabulary {
private:
    array<notion ^> ^ntn_array;

public:
    vocabulary();
    void set_array(String ^file_path, String ^lng);
};

inline vocabulary::vocabulary() { ntn_array = nullptr; }
inline void vocabulary::set_array(String ^file_path, String ^lng) {
    array<String ^> ^whole = IO::File::ReadAllLines(file_path);

    ntn_array = gcnew array<notion ^>(whole->Length); // allocate memory

    for(int i = 0; i < whole->Length; ++i) {
        array<String ^> ^current = whole[i]->Split('#');

        // THE ERROR HERE BELOW
        ntn_array[i] = gcnew word(lng, current[0], current[2], current[3]);
    }
}

class_word.h

#pragma once
#include "abstract_classes.h"

ref class word : public notion {
    String ^example;
    static int counter = 0;

public:
    word():notion("","","") { };
    word(String ^lng, String ^inscr, String ^mnng, String ^expl) :
        notion(lng, inscr, mnng), example(expl) { _id = ++counter; }

    virtual int print() override {
        return 0;
    }
};

主文件

#include "abstrace_classes.h"

int main() {



    return 0;
}

问题:

数据从文件中逐行加载到类型为 的数组中String ^。逐个元素,每一行被分成子串,并放入一个current相同类型的数组中 ContainerString ^ 类vocabulary的抽象notion从中继承word。它甚至没有在main.cpp. set_array在类方法中它vocabulary会抛出一个错误:

类型值word ^不能分配给类型实体notion ^

我想将对子类的引用分配给指向抽象类的指针。也许它在描述符中?如何使用链接而不是句柄?

наследование
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-04-07 22:11:59 +0000 UTC

为什么我们需要一个指向抽象类的指针?

  • 7

我不完全理解这个问题。请教怎么理解?

我目前对“抽象类”概念的理解是:

需要一个抽象类来禁止创建无法实现的实例。例如,有“词”的概念。这是一个抽象的概念。“词”概念的某些特征的细化已经可以实现。

例如:

#include <locale>
#include <iostream>
#include <string>

class word {
public:
    std::string _meaning;

    word() { _meaning = ""; }
    virtual void show() = 0;
};

class english_word : public word {
public:
    english_word() : word() { };
    english_word(std::string meaning) { _meaning = meaning; }

    virtual void show() override {
        std::cout << _meaning << std::endl;
    }
};


int main() {
    setlocale(LC_ALL, "RU");


    word *wrd;
    english_word ewrd("Hello");

    wrd = &ewrd; // 1
    wrd->show();

    ewrd.show(); // 2

    system("pause");
    return 0;
}

问题:

很多时候,在描述多态性时,我会遇到这样一个事实:“对后代类的引用可以分配给指向基类的指针”。但为什么 ?这也更困难.. //1 当您可以立即执行 //2 时,为什么还要执行?你能解释或建议我在哪里可以读到它吗?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-04-07 20:50:20 +0000 UTC

指向抽象类的指针。数组初始化问题

  • 2

abstract_class_word.h

#pragma once
#include <iostream>
#include <string>

class word {
protected:
    string language;
    string native_inscription;
    string translation;

public:
    word(const string &lang, const string &nat_inscr, const string &transl);

    virtual int show() = 0;
    virtual int save_to_disk() = 0;
    virtual int read_from_disk() = 0;
};


inline word::word(const string &lang, const string & nat_inscr, const string & transl) {
    language = lang;
    native_inscription = nat_inscr;
    translation = transl;
}

英语单词.h

#pragma once
#include "abstract_class_word.h"
using namespace std;

class english_word : public word {
    string example_sentence;
    static int number;
    int id;

public:
    english_word() = delete;
    english_word(const string &nat_inscr, const string &transl, const string &ex_sentence);

    virtual int show() override;
    virtual int save_to_disk() override;
    virtual int read_from_disk() override;
};


inline english_word::english_word(const string &nat_inscr, const string &transl, const string &ex_sentence) : word(string("EN"), nat_inscr, transl) {
    example_sentence = ex_sentence;
    id = ++number;
}

inline int english_word::show() {
    cout << id << "\t" << native_inscription << "\t->\t" << translation << endl;
    cout << "\t" << example_sentence << endl << endl;

    return 0;
}
inline int english_word::save_to_disk() {
    return 0;
}
inline int english_word::read_from_disk() {
    return 0;
}

int english_word::number = 0;

主文件

#include "headers\class_english_word.h"
#include <locale>

int main() {
    setlocale(LC_ALL, "RU");

    word *wrd;
    wrd = new english_word[3] { english_word("cut","рубить","Cut down those trees."),
                                english_word("run","бежать","Run, Forrest, run!"),
                                english_word("sow","сеять","You earn what you sew.") };
    english_word *ewrd;
    ewrd = new english_word[3] { english_word("cut","рубить","Cut down those trees."),
                                english_word("run","бежать","Run, Forrest, run!"),
                                english_word("sow","сеять","You earn what you sew.") };

    for(auto i = 0; i < 3; ++i)
        ewrd[i].show();

    for(auto i = 0; i < 3; ++i)
        wrd[i].show(); //<<<<<<<<<<<<<< exception!

    system("pause");
    return 0;
}

问题

在此处输入图像描述

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-01-17 23:05:37 +0000 UTC

模板类朋友方法[重复]

  • 1
这个问题已经在这里得到了回答:
引用未解决的外部元素 2 个答案
重载模板操作符分为描述和实现 1个回答
模板函数声明和定义中的不同类型名称 2 个回答
3年前关闭。

头文件.h

template <typename T>
class example {
public:
    example() { p = nullptr; };
    example(T x, T y, T z) {
        p = new Point<T>(x, y, z);
    };
    ~example() { if (p != nullptr) delete p; }

    template <typename T>
    class Point {
    public:
        Point(T x, T y, T z) {
            this->x = x;
            this->y = y;
            this->z = z;
        }

        T x, y, z;
    };

    void get_point();
    friend void set_point(example<T> & ex, T x, T y, T z);
    Point<T> * p;
};

template<typename T>
void example<T>::get_point() {
    cout << p->x << endl;
    cout << p->y << endl;
    cout << p->z << endl;
}

template<typename T>
void set_point(example<T> & ex, T x, T y, T z) {
    ex.p->x = x;
    ex.p->y = y;
    ex.p->z = z;
}

主文件

#include <iostream>
#include "header.h"
using namespace std;   


int main() {
    example<int> ex(12,20,15);
    ex.get_point();
    set_point(ex,5,25,35);
    ex.get_point();

    return 0;
}

它编译没有错误,但是当我在没有调试的情况下运行它时,它给出:

错误 LNK2019 在主函数中引用未解析的外部符号“void __cdecl set_point(class example &,int,int,int)”(?set_point@@YAXAEAV?$example@H@@HHH@Z)

并且不启动。为什么?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-01-17 19:16:02 +0000 UTC

模板继承类的朋友方法

  • 0

有两个模板类后代和一个友元函数:

header.h 文件

#pragma once
using namespace std;

template <typename T>
class _list : public list<T> {
public:
    friend void fill_int(int);
};

template <typename T>
class _vector : public vector<T> {
public:
    friend void fill_int(int);
};

template <typename T>
void fill_int(int num) {
    while (num) {
        this->push_back(rand() % 128);
        num--;
    }
}

main.cpp 文件

#include <iostream>
#include <vector>
#include <list>
#include "header.h"
using namespace std;

int main() {
    _list<int> lint;
    lint.fill_int(7); // <<<<<<< here
    return 0;
}

作为朋友的功能被移动到两个类中都可用。拒绝工作。他说:

错误 C2039 fill_int:不是“_list”的成员

c++
  • 2 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-12-31 18:07:40 +0000 UTC

按多列从sql表中选择

  • 0

我有一个带有列的 WORDS 表的 SQL 表:

#, Add Date, Date1, Date2, Date3, Date4.

您必须在五个日期的列中选择包含当前日期的那些行。我试过这样选择:

SELECT * 
FROM WORDS 
WHERE `Add Dɑte`='31.12.2018' 
   OR `Date1`='31.12.2018'

问题是这个查询只选择那些满足最后一个条件的行。但是这个日期在列Add Dɑte和所有其他列中,但在不同的行上。结果,我只得到列中Date1包含此日期的那些行。如何选择该日期包含在列Add Dɑte或以下任何内容中的所有行?

sql
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-11-15 01:02:08 +0000 UTC

模板功能描述错误

  • 0

DynamicMassives.h

//------------------------------------------------------------- create simple massive
template <typename T>
T * getArray(int &len) {        // returns pointer to dynamic massive
    T *ptr;

    if (!(ptr = new T[len])) {  // conditional of possibility of memory allocation
        cout << "can't allocate memory..." << endl;
        return nullptr;             // protection if there is no memory rest
    }
    else return ptr;
}

源码.cpp

#include <iostream>
#include <ctime>    // for random
#include "DynamicMassives.h"
using namespace std;

int main(void) {
    srand(time(NULL));  // randomize

    //----------------------------------------------- Simple dynamic massive
    cout << "simple dynamic massive:" << endl;
    int *parr;      // pointer for dynamic massive
    int len = 20;   // length of dynamic massive

    parr = getArray(len);   // call for dynamic massive creating function <<<<<<<<<<<<< ERROR!!!!

    cout << endl;
    system("pause");
}

结论:

错误 C2672“getArray”:未找到匹配的重载函数
错误 C2783 T *getArray(int &):无法为“T”编写模板参数

你能告诉我模板有什么问题吗?如果没有带有 int 的模板,它在任何地方都能完美运行。

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-08-04 14:49:33 +0000 UTC

在页面顶部填充

  • 0

我不知道缩进在页面顶部的位置

.css

* {
    font-family: calibri;
    margin:0;
}
body {
    margin:0;
    background: white;
}
.button {
    font-size: 3vw;
    border-color: #caa54c;
    background: #caa54c;
    padding:10px;
    border-radius:3px;
    margin:auto;
}
.requestbox {
    font-size: 3vw;
    width:100%;
    border-collapse:collapse;
    border-color:#3d3d3d;
    margin:auto;
}
A:link { text-decoration: none; color:white; /* Убирает подчеркивание для ссылок */ } 
A:visited { text-decoration: none; color:white;} 
A:active { text-decoration: none; }
A:hover { text-decoration: none; color: silver; }

在查看页面的代码时,我注意到以下内容: 页面代码

标签是通过 .php 插入的。我已经检查了所有内容 10 次。这种数字组合在任何地方都找不到。

php
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-08-03 06:40:28 +0000 UTC

网站未在 Android Chrome 上更新

  • 0

该网站未在 .php 上更新

写了一个简单的网站:(index.php)

<html>
    <head>
    <meta charset="utf-8">
    <link rel=stylesheet href="styles/index.css">
    <title>Test</title>
    </head>
    <body bgcolor="white">

<?php

require 'functions.php';

/********** GLOBALS ************/
$counter;
$request;
$answer;
$trans;
$today=date('d.m.Y');

DrawHead();
DrawMenu();
DrawSearchForm();

/***************************** ENGINE *******************************/
if (isset($_POST["request"])) {
        $request=$_POST["input"];
        Search($request);
}

?>

    </body>
</html>

问题:

每天都会在函数内部更新数据。从数据库(文本文件)中进行选择并使用所选数据。但问题来了..当我第二天从移动 Android Chrome 访问该站点时,数据仍然是“昨天的”。既不清除缓存,也不重新启动应用程序,也不刷新页面帮助。当您从计算机打开站点时,所有内容都会更新,然后当前信息已显示在手机上。

android
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-03-15 21:52:49 +0000 UTC

无法读取注册表项值

  • 1

注册表中有一个键:

HKEY_CURRENT_USER\Software\Posix\NetStat

并且密钥有一个值

REG_SZ带值的下载类型done

我正在尝试计算它的价值。什么都没有出来。

#include <windows.h>
#include <iostream>
#include <string>
using namespace std;


int main() {
    char buf[1024];
    HKEY hKey = HKEY_CURRENT_USER;
    ULONG result;
    DWORD sz = 1024;
    // open section and get hKey handler
    result = RegOpenKeyExA(
        hKey,
        "Software\\Posix\\NetStat",
        0,
        REG_SZ,
        &hKey);
    if (result != ERROR_SUCCESS) {
        cout << "Can't open section" << endl;
        RegCloseKey(hKey);
    }
    // get desired value
    result = RegGetValueA(
        hKey,
        "Software\\Posix\\NetStat",
        "Downloaded",
        RRF_RT_ANY,
        NULL,
        (LPDWORD)buf,
        &sz);
    if (result != ERROR_SUCCESS) {
        cout << "Can't get value of Downloaded" << endl;
        RegCloseKey(hKey);
    }
    system("pause");
    return 0;
}

第一个函数result执行后为0,即第一个函数起作用。执行第二个函数后,result它等于 2。

#define ERROR_FILE_NOT_FOUND 2L

当然,这个函数buf是不返回任何值的,这里是MSDN上函数描述的链接。只有那里RegGetValue()。

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724868(v=vs.85).aspx

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-03-12 22:15:10 +0000 UTC

将参数传递给流

  • 0

有一堂课。可以将参数传递给流。在下面的示例中,我在那里传递了一个字符串并将其输出到控制台。但问题来了,我的线程类实例不存在。也就是说,当然,我可以在线程中创建该类的另一个实例并使用它,但我想以某种方式将我使用的实例转移到线程main()。有必要访问类对象并在某些条件下更改它们。例如,更改线程中的值bool checked并执行method1().

#include <windows.h>
#include <iostream>
#include <string>
using namespace std;

class SomeClass {
public:
    SomeClass(int value) {
        this->value = value;
        checked = false;
    }
    ~SomeClass() {
        cout << "The end" << endl;
    }
    void method1() {
        cout << value;
        checked = true;
    }
private:
    int value;
    bool checked;
};


DWORD WINAPI MyThread(LPVOID param) {
    cout << ((string*)param)[0] << endl;
    system("pause");
    return 0;
}

int main() {
    SomeClass SC(5);
    SC.method1();

    DWORD thID;
    HANDLE handle;
    string str = "hello";
    handle = CreateThread(NULL, NULL, MyThread, &str, NULL, &thID);

    system("pause");
    return 0;
}

有一个这样的假设:(它有效,但我正在使用同一个实例?)

handle = CreateThread(NULL, NULL, MyThread, &SC, NULL, &thID);

和

DWORD WINAPI MyThread(LPVOID param) {
    SomeClass SC2 = ((SomeClass*)param)[0];
    SC2.method1();
    //cout << ((string*)param)[0] << endl;
    return 0;
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-03-01 23:16:19 +0000 UTC

缺少 mcvcp140.dll

  • 0

C++。在 Visual Studio 2017 中编写代码。将应用程序构建为 Release x86。我正在尝试在另一台计算机上运行它(安装了 Windows 7x64)。不启动。写入缺少 mcvcp140.dll。应该在 Visual Studio 设置中禁用或启用什么,以便在没有此组件的情况下编译项目?我知道需要在该机器上重新安装 Visual C++ 包,但我希望它在没有它的情况下也能正常工作。

c++
  • 1 个回答
  • 10 Views
Martin Hope
Григорий
Asked: 2020-02-24 18:48:12 +0000 UTC

accept() c++ 套接字的问题

  • 0

主要的

...
CreateListenSocket();
Accept();
...

服务器.cpp

...
void MCServer::CreateListenSocket() {
    // Create a socket and bound it as listening socket
    _ListenSocket = socket(AF_INET, SOCK_STREAM, 0);
    if (_ListenSocket == INVALID_SOCKET) {
        cerr << "Can't create a socket!\tError >> " << WSAGetLastError() << endl;
    }

    // Bind the ip address and port to a socket
    sockaddr_in hint = { 0 };
    hint.sin_family = AF_INET;
    hint.sin_port = htons(_port);
    hint.sin_addr.S_un.S_addr = INADDR_ANY;

    bind(_ListenSocket, (sockaddr*)&hint, sizeof(hint));

    // Tell Winsock the socket is for listening 
    listen(_ListenSocket, SOMAXCONN);
    cout << "Listen socket ready\t\tsocket: " << _ListenSocket << endl;
}
...
void MCServer::Accept() {
    _Client = accept(_ListenSocket, 0, 0);       //<<<<<<<<<< PROBLEM
}
...

服务器.h

class MCServer {
...
private:
    int                     _port;
    char*                   _buf;
    int                     _size = 4096;
    SOCKET                  _ListenSocket;
    SOCKET                  _Client;
    fstream                 _file;
    string                  _time;
    string                  _skt;
...

当服务器启动时,_Client被设置为正确的值。例如 128 或 126 或 132。达到

_Client = accept(_ListenSocket, 0, 0);

老实说等待传入的连接。当客户敲门时,它就起作用了。然后,当该客户端完成时,服务器关闭套接字并再次调用

...
CreateListenSocket();
Accept();
...

但是第二次到达

_Client = accept(_ListenSocket, 0, 0);

_Client 被分配了一个宇宙数字......就像 99895919816189 和accept()在它应该等待真正的呼叫时接受没有传入客户端的连接。但是客户端还没有连接。怎么了?

c++
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5