mirror of
https://github.com/apache/nuttx.git
synced 2026-09-01 22:53:01 +00:00
net/local:Add support for MSG_DONTWAIT to SOCK_STREAM
Signed-off-by: wangyingdong <wangyingdong@xiaomi.com>
This commit is contained in:
parent
0b2b5b781c
commit
032a456c83
1 changed files with 19 additions and 0 deletions
|
|
@ -224,6 +224,25 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* If it is non-blocking mode, the data in fifo is 0 and
|
||||
* returns directly
|
||||
*/
|
||||
|
||||
if (flags & MSG_DONTWAIT)
|
||||
{
|
||||
int data_len = 0;
|
||||
ret = file_ioctl(&conn->lc_infile, FIONREAD, &data_len);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (data_len == 0)
|
||||
{
|
||||
return -EAGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the packet */
|
||||
|
||||
ret = psock_fifo_read(psock, buf, &readlen, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue