ServerSocket doubts

hi, I use the ServerSocket to listen on a port and then pass the communication to a ClientSocket as per xojo examples. Every time the clientSocket has concluded its communication phase, I close it, with the logic of recovering resources. However, I see that the serverSocket, when it receives further requests that go beyond the 10 contained in the maximum property, recreates another 10 instances of the TCPSocket to which the requests will be passed. The question arises, when it arrives at a number whose counter will cross 65535 what should happen?

First of all it’s important to put the full names of the properties because they aren’t simple maximum and minimum values.

MaximumSocketsConnected is the maximum number of sockets that an be connected at any given time. That is, a value of 10 means that only 10 can be connected to something else at once. As soon as one of those disconnects, another socket is available for connection.

MinimumSocketsAvailable is the number of sockets that are available at any given time. Because sockets take time to spin up, an app that expects lots of quick short-lived connections might want to set this value higher to reduce connection latency.

So in essence, don’t set these two such that added together they’ll ever exceed the total number of ports available. 65536 is not the number you are looking at however. Ports 1 - 1024 are reserved for use by root and there are any number of system resources which can reserve and listen on ports. Besides, unless you have gobs of RAM, you’re more likely to run out of memory before you run out of ports.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.