NAME

catnet_setfd - register socket descriptor with I/O handler

SYNOPSIS

#include <cat/cat.h>

int catnet_setfd(cat_session *session, int fd_ids, CATSOCK sock);

DESCRIPTION

Registers a socket descriptor with the I/O handler to be used as one or more of the I/O channels for a session.

The sock argument must be a socket or the constant CATSOCK_INVALID, which will remove the current socket for the descriptor from the session but not install a new one.

The fd_ids argument can be an OR'ed combination of descriptor identifiers. The argument can also be combined with the following optional flags:

CAT_CLOSED
Closes the previous socket for the descriptor. Normally, the sockets are not touched as they are removed from the session.

CAT_LISTEN
The socket is assumed to be in listen mode. This flag must be combined with CAT_CLIENT_RFD as the only descriptor.

The function returns CAT_OK if successful, or a negative error code otherwise.

NOTES

An I/O handler must be installed for the session prior to calling this function (see cat_installiohandler()).

SEE ALSO

cat, catnet, cat_installiohandler