非阻塞式socket的问题,服务器端经常莫名死掉

sxzqlzx 2005-02-02 09:16:00
我的聊天程序的服务器端在客户端退出的时候有时回报1053,1054的错误,程序并死掉,客户端退出时加了延时也不行,请各位大侠找找原因



郁闷中...
...全文
273 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶子哟 2005-02-07
  • 打赏
  • 举报
回复
这个循环如果客户端不多或是你的处理时间不长,应该没有什么问题
sxzqlzx 2005-02-02
  • 打赏
  • 举报
回复
up
sxzqlzx 2005-02-02
  • 打赏
  • 举报
回复
上面还有。循环在这个大循环里

for (i = 0; i < ServerSocket->Socket->ActiveConnections; i++)
{
上面的循环
}

请斑竹帮助
sxzqlzx 2005-02-02
  • 打赏
  • 举报
回复
谢谢chiengod

我知道10053和54的意思是连接被强制关闭或连接部存在的意思

想知道如何避免这种情况的发生。

客户端在关闭后,服务器端要向其他的在线客户发送该客户端退出的信息,发送的客户端不包括这个退

出的客户端


if (ServerSocket->Socket->Connections[i] != TheCloseSocket)
{
ServerSocket->Socket->Connections[i]->SendText(TheCloseSocket关闭);
}

这短代码有问题吗?

chiengod 2005-02-02
  • 打赏
  • 举报
回复
WSAECONNRESET

(10054)

Connection reset by peer.

A existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, or the remote host used a "hard close" (see setsockopt for more information on the SO_LINGER option on the remote socket.)
chiengod 2005-02-02
  • 打赏
  • 举报
回复
WSAECONNABORTED

(10053)

Software caused connection abort.

An established connection was aborted by the software in your host machine, possibly due to a data transmission timeout or protocol error.

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧