diff options
author | Guoyi Tu <tugy@chinatelecom.cn> | 2022-08-23 15:50:39 +0800 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-09-29 14:38:05 +0400 |
commit | 3c63b4e94a16db730a8185278479b592f7de8b7f (patch) | |
tree | a08567d342967dd463abc5ab8a997a8013096ca2 /include/qemu | |
parent | fc0c128531ed55f058bfbad4f1348ebd9a0187f2 (diff) | |
download | qemu-3c63b4e94a16db730a8185278479b592f7de8b7f.zip qemu-3c63b4e94a16db730a8185278479b592f7de8b7f.tar.gz qemu-3c63b4e94a16db730a8185278479b592f7de8b7f.tar.bz2 |
oslib-posix: Introduce qemu_socketpair()
qemu_socketpair() will create a pair of connected sockets
with FD_CLOEXEC set
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <17fa1eff729eeabd9a001f4639abccb127ceec81.1661240709.git.tugy@chinatelecom.cn>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/sockets.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 038faa1..036745e 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -14,6 +14,24 @@ int inet_aton(const char *cp, struct in_addr *ia); /* misc helpers */ bool fd_is_socket(int fd); int qemu_socket(int domain, int type, int protocol); + +#ifndef WIN32 +/** + * qemu_socketpair: + * @domain: specifies a communication domain, such as PF_UNIX + * @type: specifies the socket type. + * @protocol: specifies a particular protocol to be used with the socket + * @sv: an array to store the pair of socket created + * + * Creates an unnamed pair of connected sockets in the specified domain, + * of the specified type, and using the optionally specified protocol. + * And automatically set the close-on-exec flags on the returned sockets + * + * Return 0 on success. + */ +int qemu_socketpair(int domain, int type, int protocol, int sv[2]); +#endif + int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int socket_set_cork(int fd, int v); int socket_set_nodelay(int fd); |