Solved

Checking how many others are connected to server.

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mysql jsp example issue 32 96
Why is enum singleton a better approach than static factory 3 65
jmeter usage 4 62
DTD and JAVA versions 1 55
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

734 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