企业服务器停止响应怎么办,服务器停止响应

服务器停止响应

This behavior occurs when multiple clients are active and any single client close. The TCP version seem to work properly because of the live connection. Nice work nevertheless...这种行为发生在多个客户端是活跃的和任何一个客户端关闭。 TCP版本似乎正常工作,因为实时连接。 好工作,不过……

I have this same issue. Not sure how or why it does it. (as I'm still learning sockets and such).我有同样的问题。 不知道为什么它。 (我仍然学习套接字等)。

I'm trying to sort this out and will get back as and when it happens. Thanks,我想重现此问题,谢谢

I figured it out! The problem is in the SGServerform.cs, OnReceive(IAsynchresult ar) function.我想出来! 问题是在SGServerform.cs,OnReceive(IAsynchresult ar)函数

The concept is that the server has to be listening for more messages from all its clients. If you noticed, after going through the switch statement the serverSocket.BeginReceiveFrom() is called, EXCEPT when a user sends the logout message.这个概念是服务器必须倾听更多的来自客户的消息。 如果你注意到,经过switch语句后调用了serverSocket.BeginReceiveFrom(),除非用户发送退出消息。

So how do we start get it to listen again (i.e. any new messages)?. Look at when the server starts in the Load function: it starts the serverSocket.BeginReceiveFrom(). This is the behavior we copy from. So in the case statement for the logout message:那么我们如何开始让它再听一遍(即任何新消息)?。 看服务器启动时加载功能:它开始serverSocket.BeginReceiveFrom()。 这是我们复制的行为。 所以在注销的case语句的信息:

Do this:这样做:

case Command.Logout:案例Command.Logout:

//When a user wants to log out of the server then we search for her

//in the list of clients and close the corresponding connection

int nIndex = 0;

foreach (ClientInfo client in clientList)

{

if (client.endpoint == epSender)

{

EndPoint testsender = (EndPoint)ipeSender;

serverSocket.BeginReceiveFrom(ReceivedData, 0, ReceivedData.Length,

SocketFlags.None, ref testsender, new AsyncCallback(OnReceive), testsender);

clientList.RemoveAt(nIndex);

break;

}

++nIndex;

}

Notice all the beginreceivefrom in the app use the endpoint of the incoming message, here we use the server's endpoint to start listening as it was done when first starting it.Hope that helps! 注意所有的beginreceivefrom应用使用传入消息的端点,这里我们使用服务器的端点开始听,因为它是第一个开始的时候完成的。 希望会有帮助!

no it doesnt work, cant find var "receivedData"idea is right, but the problem is still there.不,它不工作,不能找到var“receivedData” 想法是对的,但是问题仍然存在

Hi, try this:嗨,试试这个:

case Command.Logout:

foreach (ClientInfo client in clientList) {

if (client.endpoint.Equals(epSender)) {

clientList.Remove(client);

break;

}

}

//if (msgReceived.cmdCommand != Command.Logout) {

serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length,

SocketFlags.None, ref epSender,

new AsyncCallback(OnReceive), epSender);

//}

your two methods fixes the problem that the server is not responding any more when a user leaves the chat and the problem that the user isn't removed from the array. But there is another problem. Try to kill the chat client with the Task Manager after logging in to the server and connect again to the server. You will get the error:你的两种方法修复问题,服务器没有响应了当用户离开聊天和用户的问题不是从数组中删除。 但还有另一个问题。 试图杀死的聊天客户端任务管理器后再次登录服务器和连接到服务器。 你会得到错误:

ErrorCode: 10054

InnerException: Nothing

Message: "An existing connection was forcibly closed by the remote host"

错误代码:10054

InnerException:没有

信息:“强行关闭了一个现有的连接远程主机”

I got this problem in an application I'm trying to develop and I'm searching for a good solution to the problem. I found out that when the dead client is removed from the array and the BeginReceiveFrom is called again then the problem seems to be solved. But how do I find out which client is dead?

我有这个问题在一个应用程序试图开发,我寻找一个好的解决问题的办法。 我发现当死者端从数组中移除并再次调用BeginReceiveFrom然后问题似乎解决了。 但我怎么找出哪些客户是死了吗?

problem solved to remove dead client from the list but when this dead client second time login at that time we remove this client but this dead client not login second time at that time any other person which in network fire the messae at that time we face that same error问题解决了从列表中删除死客户,但当这死端第二次登录当时我们删除这个客户但这死客户不是登录第二次当时他人在网络火messae那时我们面临同样的错误

Then you modify SGSserverForm.cs file 然后你修改SGSserverForm。 cs文件

case Command.Logout:案例Command.Logout:

//When a user wants to log out of the server then we search for her

//in the list of clients and close the corresponding connection

/ /当用户想要退出服务器然后我们在客户列表中寻找她并关闭对应她的连接

int nIndex = 0;

foreach (ClientInfo client in clientList)

{

if (client.endpoint == epSender)

{

//epSender.

clientList.RemoveAt(nIndex);

break;

}

++nIndex;

}

msgToSend.strMessage = "<<>>";

break;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值