windows C++ 套接字的 send() 导致系统错误 10053

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5367900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:27:54  来源:igfitidea点击:

C++ socket's send() causes system error 10053

c++windowssocketssend

提问by Idov


I'm trying to send a message from my client to my server (currently they are both running in the same process, but I don't think it matters).
The connection is established well (I can see it with "CurrPorts" - much more user friendly than TcpView). But then, when I send the message, I get the error:
"An established connection was aborted by the software in your host machine." (number 10053)
and then the connection breaks...


我正在尝试从我的客户端向我的服务器发送一条消息(目前它们都在同一个进程中运行,但我认为这并不重要)。
连接建立良好(我可以通过“CurrPorts”看到它 - 比 TcpView 更加用户友好)。但是,当我发送消息时,我收到错误消息:
“已建立的连接被主机中的软件中止。” (编号 10053)
然后连接中断...

here is the relevant code:

这是相关的代码:

bool Client::Send(void* msg, int size)
{
    int sockId = m_socket.GetId();
    struct sockaddr_in remote = m_socket.GetRemotePoint().GetBasePoint();
    const char* buf = (const char*)msg;
    int error = send(sockId, buf, size, 0);
    //int g = GetLastError();
    //if (g != 0)
    //{
    //  g = g;
    //}
    return (error != -1);
}

Does anybody know what's going on?
thanks :)

有人知道这是怎么回事吗?
谢谢 :)

采纳答案by Idov

I'm so stupid... :/
I have this class MySocketwhich I create during Accept, but in its destructor, I CLOSE the socekt.
thanks everybody :)

我太愚蠢了... :/
我有这个类MySocket是在 期间创建的Accept,但是在它的析构函数中,我关闭了 socekt。
谢谢大家 :)

回答by Ben

That's WSAECONNABORTEDwhich means that your local machine has killed the connection. Possibly a firewall issue?

WSAECONNABORTED意味着您的本地机器已终止连接。可能是防火墙问题?