Best estimated buffer for an IPCSocket?

I’m using a helper app (regular console app) to talk with the main app. When the helper finds results, it reports them using an IPCSocket.
However, I’ve found common situations where the buffer gets too full; the main app receiving data hangs and the helper, unaware of this, continues to send data.
So, I’ve written this code whenever I need to send a result:

  if Search.Socket.BytesLeftToSend>20000 then 'The socket is “too full”.
    System.DebugLog "Delaying result sending…"
    app.DoEvents 'Allow bytes to be sent
    Exit 'Less or equal than 20000 bytes left to send; can send further
  end if
Search.Socket.Write chr(0)+"rslt"+What+if(Value=nil,"",Value.NativePath)+chr(4)+SearchID.ToString+chr(1) 'Message to send

However, I don’t know what is the best value to replace 20000. I guess the amount of RAM is to be taken into account, but what else? And how do we calculate this?

Arnaud - the documentation really doesn’t shed any light on this. Have you considered monitoring IPCSocket.Error and filling the buffer until it bursts?

Thanks William.
The app prefers to hang rather than the socket raising an error.
Knowing the buffer’s available size would certainly help…

The OS has a buffer, which may be 1 MB big.

1 Like

Thank you; I’ll take half of this as the maximum at once.