C++ socket的send()导致系统错误10053
我正在尝试从客户端向服务器发送消息(当前它们都在同一进程中运行,但我认为这并不重要)。
连接建立得很好(我可以用“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是
WSAECONNABORTED
,这意味着您的本地计算机已终止连接。可能是防火墙问题?That's
WSAECONNABORTED
which means that your local machine has killed the connection. Possibly a firewall issue?我真是太傻了……:/
我有一个在
Accept
期间创建的类MySocket
,但在其析构函数中,我关闭了 socekt。谢谢大家:)
I'm so stupid... :/
I have this class
MySocket
which I create duringAccept
, but in its destructor, I CLOSE the socekt.thanks everybody :)