Steve
Steve

Reputation: 65

How many people can connect to ServerSocket?

I'm working with sockets. I'd like to know how many people can connect to my SocketServer using Sockets?

According to Cameron it is 2^16 different connection. So, as much as 2^16 people can actually use my chat at the same time(resources for handling so much users and other factors are not considered)???

https://www.quora.com/How-many-connections-can-a-JAVA-socket-server-hold

Upvotes: 3

Views: 1582

Answers (2)

Stephen C
Stephen C

Reputation: 718708

The theoretical limit is 2^16 - 1. Port zero is reserved.

The practical limit will be platform specific, and can only be determined by testing.

The limiting factors will include:

  • available network throughput,
  • the number of simultaneous connections that the OS kernel can sustain,
  • the number of open file descriptors that a process is permitted, and
  • the in-process resources required to sustain a large number of active connections.

Most of those are most likely to be hardware limitations.


The limit of 50 that people are talking above in comments is the number of connection requests that can be queued. If your java application calls ServerSocket.accept() fast enough, requests won't be dropped.

Upvotes: 4

Joseph Larson
Joseph Larson

Reputation: 9058

On Mac and Linux, you can do "ulimit", which will tell you the limit defined by the operating system.

Upvotes: 0

Related Questions