* @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
| 5912 | * @see sys_send(), sys_recvfrom() |
| 5913 | */ |
| 5914 | sysret_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. |
nothing calls this directly
no test coverage detected