Decouble Peer handles and socket handles, in the same way peer handle and channel id is set up.
Alternative
Create increasing "first" socket handles. This is quite an easy fix. Great care should be taken as to not overlap with the peer handles gotten back from the modem.
Another way would be eliminating the need for actually allocating anything upon creation of the socket, but then the "right of way" is moved onto the client connecting their socket first.
Only one unconnected socket can exist in the socket set at any one time. Since the socket set checks for dublicate socket handles.
Example:
Solution
Decouble Peer handles and socket handles, in the same way peer handle and channel id is set up.
Alternative
Create increasing "first" socket handles. This is quite an easy fix. Great care should be taken as to not overlap with the peer handles gotten back from the modem. Another way would be eliminating the need for actually allocating anything upon creation of the socket, but then the "right of way" is moved onto the client connecting their socket first.