NAME

catnet_listen - set client fd in a listening state

SYNOPSIS

#include <cat/cat.h>

int catnet_listen(cat_session *lsess, const char *port);

DESCRIPTION

This function sets the CAT_CLIENT_RFD descriptor of lsess into a listening state, listening for connections to port. The port argument is a string with format ``tcp::digits'', where the digits form a valid TCP port number in base 10, or a service name. To listen only to the loopback interface, specify ``tcp:localhost:port''.

If the port number is zero, the system will assign a random port. The true number used can be extracted using catnet_getnetinfo.

A listening session cannot be used for any other purpose. If any descriptors in lsess are in use, the catnet_listen function will return CAT_EBUSY.

If the function is successful, 0 is returned and cat_poll() or catsock_run() can be used to wait for pending connections.

On error, a negative error code is returned.

SEE ALSO

cat, catnet, cat_poll, catsock_run, catnet_getnetinfo