[NUG] API 2.0
Tim Streater
timstreater at greenbee.net
Wed Mar 13 17:59:49 CDT 2019
On 13 Mar 2019, at 22:26, "npalardy at airenet.com" <npalardy at airenet.com> wrote:
>> On Mar 13, 2019, at 2:38 PM, Tim Streater <timstreater at greenbee.net> wrote:
>>
>> 3) Xojo sockets don't have a getline() method so I had to create my own
>> using socket.readall and then return data line by line, doing timeout and
>> error handling too. Fastest way (performance-wise) at the bottom was to keep
>> this sort of intermediate data in byte arrays.
>
> Right - sockets read BYTES not encoded text, lines of text, etc
>
> If thats what you need then that is effectively your "protocol" on top of the
> underlying socket (ie think HTTP which is just a well defined sequence of
> bytes defined in the RFC about how HTTP sends & receives data and how it
> should be formed)
>
> The best thing to do has always been to, in the data received event, grab all
> the bytes, shove them in a buffer and then have a timer or thread or something
> else deal with pulling out the "lines" (or whatever) from that buffer so you
> keep data coming in fast as heck
Yes, just what I ended up doing. Perhaps it would be clearer, though, if the ReadAll doc pushed us towards reading into a memoryblock, one that could be converted to a string and sanitised without being copied too often. I found I had to go back and forth between old and new framework to get what I needed, with a data copy at each stage, although I did manage to eliminate some of those.
--
Cheers -- Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.xojousers.com/pipermail/nug_xojousers.com/attachments/20190313/1d8997cb/attachment.htm>
More information about the Nug
mailing list