I am building a client-server system where the client sends SQL commands to the server via an EasyTCPSocket, and the server runs the SQL and returns the RecordSet. It is working well.
Given that there may be gaps of a few minutes (or longer) between client conversations with the server:
should I get the client to Close the EasyTCPSocket after each use?
If I don’t close the EasyTCPSocket, will it reuse the same EasyTCPSocket on next connection or create a new one, clogging up the server until they timeout?
If I don’t close the EasyTCPSocket, will the max socket connections be reached quickly if lots of Xojo clients are connecting (assuming the number of clients is less than MaximumSocketsConnected)?
Is there a problem if I DO close the EasyTCPSocket after each use, other than the delay time to re-connect?
I am erring on the side of closing the EasyTCPSocket so the server load will be minimised and can support more clients. Am I wrong? The clients will never be really ‘chatty’, talking at most once per minute.
I have done what you’ve suggested (not close the EasyTCPSocket) and it is working faster (obviously).
Am I correct in assuming that:
as clients quit/disconnect that the EasyTCPSocket will go back into the pool immediately?
with the EasyTCPSockets now permanently open during a client session, the number of clients that I can support is essentially MaximumSocketsConnected (since they are never disconnect during a session)?
There is no pool unless you specifically created a pool. Pools are generally used to maintain a number of connections that can be re-used once they are done doing whatever they needed. I believe what you mean is does the port become available once the connection is disconnected. Yes it does. However that does not necessarily mean the server is still listening.
Available memory, operating system configuration, etc. There is a finite number of ports and connections you can maintain at any one time. From Wikipedia “A port number is a 16-bit unsigned integer, thus ranging from 0 to 65535”. You may want to read about ServerSocket to make listening and responding to connections easier.