Solved

Checking how many others are connected to server.

Posted on 2004-04-08
6
186 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

705 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