Well it sounds, from the comments made by you and me, that the key is to send a prefix length in some fixed number of octets, which then describes how many data octets to expect in your next read.
The process only secondarily depends on asynchronous/synchronous behavior. You really should block, somewhere, until you receive the proper number of bytes, or generate a timeout error on missing data. And the prefix length (which itself has a known length) tells you what to expect.
Thank you...
I am aware of the implementation dependent solutions regarding networking.
However, if you stick to USOCKET, would it be better to switch to an explicit loop, or is there some other incantation you could use to avoid the hanging read?
Thanks
Marco
It sounds like you are using TCP/IP (the streaming protocol) vs UDP?
I have had tremendous success using the LW Asynchronous Socket interface for socket streams (TCP/IP). Size of sent phrases seems to make no difference to its performance. My transfers have arbitrary sizes and have no predictable length.
I do use a self-synchronizing encoding (Phuang) across the wire, and I think that ultimately becomes a length-prefix followed by data octets. And these packets come in a variety of sizes.
> On Dec 17, 2025, at 01:01, Marco Antoniotti <marco.antoniotti@unimib.it> wrote:
>
> Hi
>
> I am reading from a uosocket:stream-usocket. My sequence is 100 octets long, but I know the other party is sending UP TO 100 octets.
>
> If the other party sends less than 100 octets, read-sequence/usocket-stream (at least the version on LW) hangs.
>
> Should I just do a loop, checking for the "end marker"?
>
> Thanks
>
> All the best
>
> --
> Marco Antoniotti
--