I have a java program which runs as a server accepting connections, and I connect Android clients to it. Clients are connected for a long time to their sockets.
1) How many clients can I server concurrently have (in practice - im not talking about the number of ports now) on an average machine with 3 Gb RAM?
2) If the phone uses 3G for the connection, is it possible that the socket is broken? If it is, how do I recover it or should it be done from the client side? Or is it done automatically? Does it happen often?
1) Depends on the what the server does for the clients. If the server just accepts the connection and does nothing more it can probably serve tens of thousands of clients. If the server does something that requires CPU, memory or I/O it can serve fewer clients.
2) Yes, TCP connections can break, even over wired networks. If the link comes back the socket connection is not broken; TCP handles the retransmission of lost data. The problem is, what happens if the link doesn't come back? If you use SO_KEEPALIVE the connection will be closed eventually, but since the default timeout is 2 hours applications sensitive to this issue implement their own timeout mechanisms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With