Archived
This forum has been archived. Please start a new discussion on GitHub.
Help! How can I get the Server's Connections number?
Hi Guys!
I want to get the current server's connections number, the code should run at server, How can I do it? thanks a lot!
Best regards!
Dongri Li
I want to get the current server's connections number, the code should run at server, How can I do it? thanks a lot!
Best regards!
Dongri Li
0
Comments
-
Do you mean the IP address of the client? In this case, you can use something like:
void HelloI::sayHello(const Current& current) { cout << current.con->toString() << endl; }
0 -
Do you mean the IP address of the client? In this case, you can use something like:
void HelloI::sayHello(const Current& current) { cout << current.con->toString() << endl; }
hi mattew
Thanks for your reply.
i want to know the client count connected to the server.
for exsample
server ip:127.0.0.1
port: 12345
I have 3 clients
ip:127.0.0.1
port: Automatic distribution
If these clients connected to the server
My First demand is count the clients connections.
I can user some functions to get the number of server's connections.
OK, If the First question be ok, Now the Second demand is
insert those connections to a vector or list, etc.like this vector<Ice::ConnectionPtr> vcp, List<Ice::ConnectionPtr> lcp.
If we use this method, we can use vcp.size(), lcp.size() to obtain the connections number,
And If we need we can user the ConnectionPtr to close the connection manually.void HelloI::sayHello(const Current& current) { cout << current.con->toString() << endl; }
the code maybe not conform my demand.
If the client discounted, the server may not know.0 -
What do you really want to do that for? In general, you should not use connections in this way, since unless you specifically disable it the Ice runtime will connect & disconnect clients without your knowledge. Unless you have a very specific use-case, then you should almost certainly use sessions instead. Take a look at the session demo demo/Ice/session for an example.0
-
What do you really want to do that for? In general, you should not use connections in this way, since unless you specifically disable it the Ice runtime will connect & disconnect clients without your knowledge. Unless you have a very specific use-case, then you should almost certainly use sessions instead. Take a look at the session demo demo/Ice/session for an example.
Hi matthew.
If I kill the client's process Non-normal, the server can't know it. Maybe session is a good suggestion,I will try it. Thanks a lot!0 -
Yes, that is precisely what sessions are designed to tell the application. Connections are not a good measure of whether the client dead, since for scalability & connectivity you want to allow connections to go up & down as needed. Connection loss is also not a good way to detect the client going away, since the connection loss notification may not be timely. For example, if you pull ethernet cable on the client box, the server may not get the connection loss notification for quite some time.0
-
Yes, that is precisely what sessions are designed to tell the application. Connections are not a good measure of whether the client dead, since for scalability & connectivity you want to allow connections to go up & down as needed. Connection loss is also not a good way to detect the client going away, since the connection loss notification may not be timely. For example, if you pull ethernet cable on the client box, the server may not get the connection loss notification for quite some time.
As you said,that isn't a good measure of whether the client dead.But if I use ICE in my IM system(server, client).IM server should know the number of clients. Although the client isn't dead, but it can't connect to the server, in this case, server must know the client disconnected and delete the user information from vector or list,etc.0 -
That's precisely what sessions are good for It is a much more reliable mechanism than a dropped connection.0