Hello I have noticed that when I have a disconnect from a socket spawned and managed by ServerSockets that it won’t respawn back to listening after the disconnect. I guess I didn’t expect it to, but I can’t figure out via LR how to make this happen. If I have 50 listening sockets and then I have 5 connections then disconnections I want to get back to 50 listening sockets. I figure that something in the ServerSocket.AddSocket has to happen so any help is appreciated as always
Set MinimumSocketsAvailable to 50. It will call AddSocket enough times to keep 50 in play. (Btw, they won’t actually be listening, only the ServerSocket listens. The regular sockets are there to hand the connection off to so the server can keep listening.)
Awesome and thanks Tim. This is the first time I am using Serversockets.
Tim how does this code give me 22 available sockets? I can’t figure out how its calculating.
GrandCentralSockets.MaximumSocketsConnected = 12
GrandCentralSockets.MinimumSocketsAvailable = 12
I would sum to 24 here.
Yes you would think, but I get 22 actual sockets not counting the server socket. Plus I wouldn’t expect it to count the Min + the Max based on what the LR says.
The Minimum is, well, the minimum. At least this many, not exactly this many. The ServerSocket may (and apparently did) request more that that so it will remain above the minimum. Frankly, I don’t know what the serversocket is thinking.
MaximumConnected is not related at all to MinimumAvailable. Totally different thing.
Your MaximumConnected says, Only 12 connections at a time. The 13th will be rejected. You probably want more than that.
I was just playing with the smaller numbers as I was connecting to see what happens. Thanks again for all your help!
FWIW and it is an old post by Aaron Ballman when he worked for Real Studio / Xojo on this topic.
[quote]Here’s how it’s supposed to go:
- We add 10 + min connections. This is arbitrary and may change in
- Connections come in over time
- Your available socket pool gets lower.
- We add more sockets as we see fit.
- More connections come in, etc.
We still honor the max connections property in that we will never
allow more than that many active connections at once. But this
doesn’t mean we’ll add all those sockets when you first call .Listen.
That’s what min sockets available is for. [/quote]