From 791069acf14e35c96474b55daf2f72584ee9c54e Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Fri, 13 Dec 2019 12:56:22 +0100 Subject: [PATCH] posix_sockets: provide function to check if file descriptor is a socket --- sys/posix/sockets/posix_sockets.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/posix/sockets/posix_sockets.c b/sys/posix/sockets/posix_sockets.c index 034bb1f911..2ba1658f37 100644 --- a/sys/posix/sockets/posix_sockets.c +++ b/sys/posix/sockets/posix_sockets.c @@ -1066,6 +1066,11 @@ int setsockopt(int socket, int level, int option_name, const void *option_value, #endif } +bool posix_socket_is(int fd) +{ + return IS_USED(MODULE_SOCK_ASYNC) && (_get_socket(fd) != NULL); +} + /** * @} */