Socket编程-Java - 许多客户机的一个插座问题(S) [英] Socket Programming -Java - Many Clients One Socket Question(s)
问题描述
基本上我试着让很多很多的Java客户端连接到插座我的ColdFusion服务器上(使用Socket网关)。不过之前我甚至开始$ C C这个$,关于插座和他们的表现我是个有点困惑。首先,是插座的意思,用于连接到一个插座多(1000+)客户端(比如端口2202)一台服务器上?是怎样的性能,如果都在那里等着基本上是平,或东西,这样当这些客户端收到这个平,他们可以得到一些新的数据。
Essentially Im trying to get many many java clients connect to a socket on my ColdFusion server (Using the Socket Gateway). However before i even start to code this, Im a little confused about sockets and their performance. First of all, are sockets meant for many(1000+) clients connecting to one socket (say port 2202) on one server? How is the performance if all there waiting for is basically a ping, or something such that when these clients receive this "ping" they can go get some new data.
谢谢, 费萨尔阿比德
推荐答案
插座是由下列元组标识,
Socket is identified by following tuple,
- 在源IP
- 在源端口
- 目标IP
- 目标端口
- 在协议(TCP或UDP)
甚至1000的客户端都连接到同一个端口(目的端口),每个将获得自己的插槽。所以,你将有1000插槽开放。
Even 1000 clients all connect to the same port (dest port), each will get its own socket. So you will have 1000 sockets open.
这将是很难维持1000插座与阻塞I / O,这通常意味着1000线程。您需要使用NIO。我们有一台服务器写入米娜,它可以处理2000连接在高峰。
It's going to be tough to maintain 1000 sockets with blocking I/O, which usually means 1000 threads. You need to use NIO. We have a server written with Mina, which can handle 2000 connections at peak.
这篇关于Socket编程-Java - 许多客户机的一个插座问题(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!