> On 10 Apr 2020, at 18:03, Jeffrey Kain via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> First, the maximum size of a text variable isn't 32000 bytes anymore, which 
> leads me to believe this was an oversight and not a feature... :)

Yes, I know. But it’s not related. It is just a convenient default value that 
is reasonable for many cases. If you need more, then you can change it easier 
than starting this discussion ;-)

> Second, it was easy to receive text until a stop character is received, as 
> long as the data is less than 32K.  When your packets become larger than 32K 
> it becomes more complicated.  In my use case it was easy since we'll only 
> ever receive one 'packet' per connection, but the code grows more complicated 
> if you need to support an arbitrary number.
> 
> What's the problem with removing the arbitrary 32K limit?

When you program in C, you first need to allocate a buffer at a particular 
size. You can then read data from the stream, which is then copied into this 
buffer.
If I would increase the limit to 4GB, then each time I would have to allocate a 
buffer of continuous memory of 4GB. Even when only 60 bytes are available in 
the stream. Your computer will not like that as it consumes too many resources. 
Now if you do not like the default buffer size, you can increase it easily by 
just changing the parameter. 

Another thing to keep in mind is that when you all TCP Receive, is that data 
arrives in smaller chunks. For example, when you send a 4GB file over the 
network, it arrives in chunks. Each time you call TCP Receive you read a chunk 
from the stream. You will need multiple cals to TCP Receive, to read chunky by 
chunk and concatenate the results.

Finally also keep in mind that TCP Receive expects UTF-8 encoded strings, which 
is OK for simple text-based protocols. But for most scenarios you should use 
TCP Receive Blob because it allows arbitrary binary data.

HTH,

- Rob Laveaux

--------------------------------------------------------
Pluggers Software
Scholekstersingel 48
2496 MP  Den Haag
The Netherlands

Email: rob.lave...@pluggers.nl
Website: http://www.pluggers.nl

--------------------------------------------------------



**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to