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

Function sys_socketpair

components/lwp/lwp_syscall.c:6255–6277  ·  view source on GitHub ↗

* @brief Creates a pair of connected sockets. * * This system call creates two connected sockets that can be used for bidirectional communication * between processes or threads. The sockets are returned as file descriptors in the `fd` array. * * @param[in] domain Specifies the protocol family to be used for the sockets. Common values include: * - `AF_UNIX`: Local commu

Source from the content-addressed store, hash-verified

6253 * @see sys_socket(), sys_close()
6254 */
6255sysret_t sys_socketpair(int domain, int type, int protocol, int fd[2])
6256{
6257#ifdef RT_USING_SAL
6258 int ret = 0;
6259 int k_fd[2];
6260
6261 if (!lwp_user_accessable((void *)fd, sizeof(int [2])))
6262 {
6263 return -EFAULT;
6264 }
6265
6266 ret = socketpair(domain, type, protocol, k_fd);
6267
6268 if (ret == 0)
6269 {
6270 lwp_put_to_user(fd, k_fd, sizeof(int [2]));
6271 }
6272
6273 return ret;
6274#else
6275 return -ELIBACC;
6276#endif
6277}
6278
6279/**
6280 * @brief Closes an open socket.

Callers

nothing calls this directly

Calls 3

lwp_user_accessableFunction · 0.85
socketpairFunction · 0.85
lwp_put_to_userFunction · 0.85

Tested by

no test coverage detected