C++ socket的send()导致系统错误10053

发布于 2024-10-25 12:28:32 字数 587 浏览 4 评论 0原文


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

这是相关代码:

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);
}

有人知道发生了什么事吗?
谢谢 :)

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...

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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷…雨湿花 2024-11-01 12:28:32

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

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

童话里做英雄 2024-11-01 12:28:32

我真是太傻了……:/
我有一个在 Accept 期间创建的类 MySocket,但在其析构函数中,我关闭了 socekt。
谢谢大家:)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文