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

Function sys_send

components/lwp/lwp_syscall.c:6142–6169  ·  view source on GitHub ↗

* @brief Sends data over a connected socket. * * This system call sends data from the specified buffer through a connected socket. It is typically * used with connection-oriented sockets (e.g., TCP) but can also work with connectionless sockets * (e.g., UDP) if a connection is established using `sys_connect()`. * * @param[in] socket The socket descriptor used for sending data. It must be a

Source from the content-addressed store, hash-verified

6140 * @see sys_sendto(), sys_sendmsg(), sys_recv()
6141 */
6142sysret_t sys_send(int socket, const void *dataptr, size_t size, int flags)
6143{
6144 int flgs = 0;
6145 int ret = 0;
6146 void *kdataptr = RT_NULL;
6147
6148 if (!lwp_user_accessable((void *)dataptr, size))
6149 return -EFAULT;
6150
6151 kdataptr = kmem_get(size);
6152 if (kdataptr == RT_NULL)
6153 {
6154 return -ENOMEM;
6155 }
6156
6157 if (lwp_get_from_user(kdataptr, (void *)dataptr, size) != size)
6158 {
6159 kmem_put(kdataptr);
6160 return -EINVAL;
6161 }
6162
6163 flgs = netflags_muslc_2_lwip(flags);
6164 ret = sendto(socket, kdataptr, size, flgs, NULL, 0);
6165
6166 kmem_put(kdataptr);
6167
6168 return (ret < 0 ? GET_ERRNO() : ret);
6169}
6170
6171/**
6172 * @brief Creates a new socket for communication.

Callers

nothing calls this directly

Calls 6

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
netflags_muslc_2_lwipFunction · 0.85
sendtoFunction · 0.85

Tested by

no test coverage detected