From c8c392050069f9a6b922ccd8ea8a4c71dda4a2c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 14 Mar 2009 18:29:38 +0100 Subject: socket_util: added socket_bind_listen() Moved code from listen_add_address() (listen.c) to socket_util.c. --- src/socket_util.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/socket_util.h') diff --git a/src/socket_util.h b/src/socket_util.h index b54897b99..dc129df40 100644 --- a/src/socket_util.h +++ b/src/socket_util.h @@ -43,4 +43,24 @@ struct sockaddr; char * sockaddr_to_string(const struct sockaddr *sa, size_t length, GError **error); +/** + * Creates a socket listening on the specified address. This is a + * shortcut for socket(), bind() and listen(). + * + * @param domain the socket domain, e.g. PF_INET6 + * @param type the socket type, e.g. SOCK_STREAM + * @param protocol the protocol, usually 0 to let the kernel choose + * @param address the address to listen on + * @param address_length the size of #address + * @param backlog the backlog parameter for the listen() system call + * @param error location to store the error occuring, or NULL to + * ignore errors + * @return the socket file descriptor or -1 on error + */ +int +socket_bind_listen(int domain, int type, int protocol, + const struct sockaddr *address, size_t address_length, + int backlog, + GError **error); + #endif -- cgit v1.2.3