StdOut cutting JSON?

I am using a console helper application with a direct shell write/stdout write communication to handle device interaction with a desktop app.
So far fine and nothing new. Only I suddenly encounter problems when I try to send a JSONItem.toString – it is simply cut after a bit more than 1000 characters (on macOS, did not check Windows yet). I flush stdout and do an error check, but everything looks fine.
Are there any limitations to the size packet I can send here?

I remember a similar restriction when I had the bad idea to use a Python app as helper app. You need to use sockets for communication.

Thanks, Beatrix!
Yes, I checked the size of the string now and it was in this case 1970 characters long. whereas it is cut in console output to exactly 1024 bytes. Funny I can usually print as much as I want into the console.
Is there some documentation on this behaviour?

Hmm, IPCSockets are so … sockety … especially on Windows where you must not connect to several at one time.
Guess I’ll install a package handling that bundles bigger strings into nice small presents.

If you do decide to use a socket, be wary of the additional requirements added to your application. If your app doesn’t already ask for network connectivity, it will start. I built a system for some of my products to communicate from the HTMLViewer back to the Xojo code via XHR and had to pull it due to customer privacy concerns.

Your best bet is probably to chunk the return data if there’s not a workaround for the size of the stdout packet size, or IPCsocket. IPCSocket shouldn’t throw up network communication warnings.

Just a bit of off-the-cuff untested chunking.

[code]dim sourceString as String = “Some really long data”
dim sourceLen as Integer = sourceString.Len
dim packetSize as Integer = 1000
stdout.Write( chr(0) ) '// Use something here to notify that a packet is incoming, and that anything which follows is part of that packet.

dim i as Integer
for i = 1 to sourceLen step packetSize
stdout.Write( sourceString.Mid( i, packetSize ) )

if i < sourceLen then
stdout.Write( sourceString.Mid( i, sourceLen - i ) )
end if

stdout.Write( chr(1) ) '// We’re done![/code]

Thanks, Anthony!
As a matter of fact, I left IPCSockets because of the simultaneous connection handshake limitations on Windows.
I use pure text handling for the communication so I implemented own tags to mark packages. Works nicely and fast – but I’d sure like to know where the 1 kB limitation comes from.

This is the answer (although not the reason)

and the limit seems to be 1 KB for a StdOut.WriteLine although one usually can write long text without problems into console …

I can’t seem to reproduce this. In a Mac Desktop app I created an Interactive Shell (mode = 2), and Executed “bash”. Then on each DataAvailable, I Sh.WriteLine "echo " + A2KString. When I compare the results on the next iteration of DataAvailable, it is always the string I sent.

You can try StdOutMBS class instead.

I did, and it was the same.
Remarkable that after a while running inside the Desktop app’s shell, StdOut says it has an error, but the main app clearly receives the full data.