Solved

Checking how many others are connected to server.

Posted on 2004-04-08
6
184 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
  • 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 63 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 62 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 57
xampp tool 12 56
hibernate example for saving data 19 55
jboss 7.1 start up error 1 40
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

828 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