Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Checking how many others are connected to server.

Posted on 2004-04-08
6
Medium Priority
?
189 Views
Last Modified: 2010-03-31
Im writing a Chat program at the moment.
I have the ChatApplet and the Server.
Is there anyway I can check(from the ChatApplet) how many people are connected to a particular port?
For example, If you open the socket and there is already 5 people connected to a server, dont allow any more connections.

Hope i'm being clear enough!

Thanks.
0
Comment
Question by:credit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 

Author Comment

by:credit
ID: 10784919
I should have said:

For example, If you open the socket and there is nobody else there then dont allow the ChatApplet to connect.
So there has to be at least one other person on the server for ChatApplet to connect.

I should say that its a type of Tech support application so i will be using a ceperat Applet for the 'Agent'!
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 252 total points
ID: 10784997
the server should know how many active clients there are.
you can have your server send a message to your client when the maximum active clients limit is reached.
if the client receives that message, then you do what you need to do (display message or try another server/port).
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 248 total points
ID: 10789395
I'm assuming you're using stream sockets and not datagram sockets. ServerSocket has a constructor which takes 2 arguments - the port number and the maximum number of connections. You can set that limit to whatever amount you want and then the ServerSocket will itself refuse more connections.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10958819
Please proceed with that recommendation.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question