libdill: Structured Concurrency for C

NAME

ipc_listen_mem - start listening for incoming IPC connections

SYNOPSIS

#include <libdill.h>

int ipc_listen_mem(const char *addr, int backlog, void *mem);

DESCRIPTION

IPC protocol is a bytestream protocol (i.e. data can be sent via bsend() and received via brecv()) for transporting data among processes on the same machine. It is an equivalent to POSIX AF_LOCAL sockets.

This function starts listening for incoming connection on file specified in addr argument. backlog is the maximum number of connections that can be held open without user accepting them.

The socket is allocated in user-supplied memory. The memory is passed in mem argument. It must be at least IPC_LISTENER_SIZE bytes long and can be deallocated only after the socket is closed. Unless you are hyper-optimizing use ipc_listen() instead.

The socket can be cleanly shut down using ipc_close() function.

RETURN VALUE

The function returns the handle of the listening socket. On error, it returns -1 and sets errno to one of the values below.

ERRORS

EXAMPLE

char mem[IPC_LISTENER_SIZE];
int s = ipc_listen_mem("/tmp/test.ipc", 10, mem);