我在 Windows Server 2003 中可以拥有的打开套接字数量的上限是多少 [英] What is the upper limit on the number of open sockets I can have in Windows Server 2003

查看:38
本文介绍了我在 Windows Server 2003 中可以拥有的打开套接字数量的上限是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 .NET 构建一个聊天服务器.我尝试打开大约 2000 个客户端连接,但我的 Linksys WRT54GL 路由器(带有番茄固件)每次都死机了.当我在 Azureus bit-torrent 客户端上打开多个连接时,也会发生同样的事情.

I'm building a chat server with .NET. I have tried opening about 2000 client connections and my Linksys WRT54GL router (with tomato firmware) drops dead each time. The same thing happens when I have several connections open on my Azureus bit-torrent client.

我有三个问题:

  1. Windows Server 2003 中的打开套接字数量是否有限制?
  2. Linksys 路由器是否有问题?如果是这样,是否有更好的硬件推荐?
  3. 有没有办法共享套接字,以便我可以用更少的资源处理更多打开的客户端连接?

推荐答案

正如我之前提到的,RaymondChen 对这类问题提出了很好的建议:如果您必须询问操作系统限制,您可能做错了什么.IP 协议只允许最多 65535 个端口,其中许多是保留的,不可用于一般用途.我建议您需要更详细地考虑您的消息传递协议,以便操作系统限制不是问题.我相信有很多很好的资源来描述这样的系统,而且这里肯定有人会对此有很好的想法.

AS I've mentioned before, Raymond Chen has good advice on this sort of question: If you have to ask about OS limits, you're probably doing something wrong. The IP protocol only allows for a maximum of 65535 ports and many of these are reserved and not available for general use. I would suggest that your messaging protocols need to be thought out in more detail so that OS limits are not an issue. I'm sure there are many good resources describing such systems, and there are certainly people here that would have good ideas about it.

我将提出一些关于实现可扩展聊天服务器的想法.

I'm going to put some thoughts about implementing a scalable chat server.

首先,在服务器上指定一个端口供客户端进行通信.每当客户端需要更新聊天状态(例如新用户消息)时,请执行以下操作:

First off, designate a single port on the server for clients to communicate through. Whenever a client needs to update the chat state (a new user message for example) do the following:

create message packet
open port to server
send packet
close port

服务器然后执行以下操作:

The server then does the following:

connection request received
get packet
close connection
process packet
for each client that requires updating
  open connection to clients
  send update packet
  close connection

当开始新的聊天会话时,开始会话的客户端会向服务器发送一条新会话"消息,其中包含客户端用户详细信息和 IP 地址以供响应.服务器创建一个新的聊天会话并使用会话 ID 进行响应.然后客户端发送包含用户键入的消息的数据包,服务器处理它们并将消息转发到同一会话中的其他客户端.当客户端离开聊天时,它会向服务器发送结束会话"消息.服务器从会话中删除客户端,并在会话中没有更多客户端时销毁会话.

When a new chat session is started, the client starting the session sends a 'new session' message to the server with the clients user details and IP address for responses. The server creates a new chat session and responds with the session ID. The client then sends packets containing the messages the user types, the server processes them and forwards the message to other clients in the same session. When a client leaves the chat, it sends a 'end session' message to the server. The server removes the client from the session and destroys the session when there are no more clients in the session.

希望能让你思考.

这篇关于我在 Windows Server 2003 中可以拥有的打开套接字数量的上限是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆