From 737eccf1ef3c0d8811aecdbccf8eead210e76335 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Mon, 27 Apr 2015 09:00:38 +0300 Subject: QNativeSocketEngine: add sendmsg(), recvmsg() wrappers on unix These functions are useful to pass ancillary data such as extended errors, IP options, protocol control information. Change-Id: I27574f73a60909c7199027160ca4689511e56b72 Reviewed-by: Thiago Macieira --- src/network/socket/qnet_unix_p.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/network/socket/qnet_unix_p.h') diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h index 979afb82ba..cd118afd63 100644 --- a/src/network/socket/qnet_unix_p.h +++ b/src/network/socket/qnet_unix_p.h @@ -193,6 +193,32 @@ static inline int qt_safe_sendto(int sockfd, const void *buf, size_t len, int fl return ret; } +static inline int qt_safe_recvmsg(int sockfd, struct msghdr *msg, int flags) +{ + int ret; + + EINTR_LOOP(ret, ::recvmsg(sockfd, msg, flags)); + return ret; +} + +// VxWorks' headers do not specify any const modifiers +static inline int qt_safe_sendmsg(int sockfd, const struct msghdr *msg, int flags) +{ +#ifdef MSG_NOSIGNAL + flags |= MSG_NOSIGNAL; +#else + qt_ignore_sigpipe(); +#endif + + int ret; +#ifdef Q_OS_VXWORKS + EINTR_LOOP(ret, ::sendmsg(sockfd, (struct msghdr *) msg, flags); +#else + EINTR_LOOP(ret, ::sendmsg(sockfd, msg, flags)); +#endif + return ret; +} + QT_END_NAMESPACE #endif // QNET_UNIX_P_H -- cgit v1.2.3