From 4bd506b7f5ce5ee041432061ae48a51b9c66ff5d Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 6 Aug 2020 10:50:56 +0900 Subject: [PATCH] apps/examples/usrsocktest: Add MSG_PEEK flag support Do not decrement the recv_avail_bytes if MSG_PEEK flag is specified. --- examples/usrsocktest/usrsocktest_daemon.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/usrsocktest/usrsocktest_daemon.c b/examples/usrsocktest/usrsocktest_daemon.c index f92e5705f..0c11a445f 100644 --- a/examples/usrsocktest/usrsocktest_daemon.c +++ b/examples/usrsocktest/usrsocktest_daemon.c @@ -879,7 +879,12 @@ prepare: { char tmp = 'a' + i; - tsock->recv_avail_bytes--; + /* Check if MSG_PEEK flag is specified. */ + + if ((req->flags & MSG_PEEK) != MSG_PEEK) + { + tsock->recv_avail_bytes--; + } wlen = write(fd, &tmp, 1); if (wlen < 0)