libdill: Structured Concurrency for C

NAME

tcp_listen - start listening for incoming TCP connections

SYNOPSIS

#include <libdill.h>

int tcp_listen(const struct ipaddr *addr, int backlog);

DESCRIPTION

TCP protocol is a bytestream protocol (i.e. data can be sent via bsend() and received via brecv()) for transporting data among machines.

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

The socket can be cleanly shut down using tcp_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

struct ipaddr addr;
int rc = ipaddr_local(&addr, NULL, 5555, 0);
int s = tcp_listen(&addr, -1);