ServerSocket Question

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. :slight_smile: I figure that something in the ServerSocket.AddSocket has to happen so any help is appreciated as always :slight_smile:

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. :wink:

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.

Thanks Tim.

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. :slight_smile: 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:

  1. Listen
  2. We add 10 + min connections. This is arbitrary and may change in
    the future.
  3. Connections come in over time
  4. Your available socket pool gets lower.
  5. We add more sockets as we see fit.
  6. 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]

Original Real Studio Forum Post