MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_recv

Function sys_recv

components/lwp/lwp_syscall.c:5914–5936  ·  view source on GitHub ↗

* @brief Receives data from a connected socket. * * This system call is used to receive data from a socket that is in a connected state. * It supports various flags to modify the behavior of the receive operation. * * @param[in] socket The socket descriptor from which the data will be received. * The socket must be in a valid and connected state. * @param[out] mem

Source from the content-addressed store, hash-verified

5912 * @see sys_send(), sys_recvfrom()
5913 */
5914sysret_t sys_recv(int socket, void *mem, size_t len, int flags)
5915{
5916 int flgs = 0;
5917 int ret;
5918 void *kmem = RT_NULL;
5919
5920 if (!lwp_user_accessable((void *)mem, len))
5921 return -EFAULT;
5922
5923 kmem = kmem_get(sizeof(*kmem));
5924 if (kmem == RT_NULL)
5925 {
5926 return -ENOMEM;
5927 }
5928
5929 flgs = netflags_muslc_2_lwip(flags);
5930 ret = recvfrom(socket, kmem, len, flgs, NULL, NULL);
5931
5932 lwp_put_to_user((void *)mem, kmem, len);
5933 kmem_put(kmem);
5934
5935 return (ret < 0 ? GET_ERRNO() : ret);
5936}
5937
5938/**
5939 * @brief Sends a message from a socket using scatter-gather I/O.

Callers

nothing calls this directly

Calls 6

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
netflags_muslc_2_lwipFunction · 0.85
recvfromFunction · 0.85
lwp_put_to_userFunction · 0.85
kmem_putFunction · 0.85

Tested by

no test coverage detected