ud3tn/include/platform/posix/socket_util.h
Felix Walter 485a06b381 AAP, AAP2: Move common socket handling parts to dedicated module
There is some common functionality that should not be copied.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-09 14:33:48 +01:00

22 lines
700 B
C

// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
#ifndef SOCKET_UTIL_H_INCLUDED
#define SOCKET_UTIL_H_INCLUDED
/**
* Create a new UNIX domain socket at the given path.
*
* @param path The path to the socket file.
* @return the socket file descriptor, -1 on error.
*/
int create_unix_domain_socket(const char *path);
/**
* Wait for incoming data using poll() and indicate common errors.
*
* @param socket_fd The socket to be polled.
* @param timeout The maximum number of milliseconds to wait for data.
* @return 1 if there is data to be read, 0 if the timeout passed, -1 on error.
*/
int poll_recv_timeout(const int socket_fd, const int timeout);
#endif // SOCKET_UTIL_H_INCLUDED