Skip to content
Commit 1fa2ea1c authored by Christopher Friedt's avatar Christopher Friedt Committed by Carles Cufi
Browse files

net: sockets: tcp: split recv_stream into immediate and timed



Previously, if a net_context had multiple packets already in
the receive queue, and a call to zsock_recvfrom() was made with
a buffer large enough to receive content from multiple packets,
only the content from a single receive buffer would be received.

Since zsock_recvfrom() is a system call, which has a
non-negligible overhead, it makes sense to receive as many bytes
as possible per system call.

Add zsock_recv_stream_immediate() as a shorthand for
"fill this receive buffer with as many bytes as possible without
blocking". Allow nullable buffer parameters so that we can also
have a shorthand for "count how many bytes are immediately
available".

With minor refactoring, zsock_recv_stream_timed() is a simple
wrapper around zsock_recv_stream_immediate() that handles timing
and error conditions.

Signed-off-by: default avatarChristopher Friedt <cfriedt@meta.com>
parent d4e33c57
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment