Solved

Checking how many others are connected to server.

Posted on 2004-04-08
6
181 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:mayankeagle
mayankeagle 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:mayankeagle
ID: 10958819
Please proceed with that recommendation.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now