catgen_listen - install listener sessions
#include <cat/gen.h>
int catgen_listen(catgen_sessfunc *func, void *data);
This function starts listening to all sockets as specified on the command
line by -P arguments. The arguments must have been parsed by
catgen_parseargs() or catgen_getopt().
The func argument is an event callback that will be invoked when a new connection is
received. func can be supplied as NULL.
A catgen_sessfunc is defined as follows:
typedef int catgen_sessfunc(cat_session *sess, const char *port, void *data);
The sess parameter is the current session, the port parameter is the local port number specified as a string, and data is the data passed to catgen_listen. The function should return CAT_CONTINUE if the SDK is to continue to forward data between the server and client.
Depending on platform, configuration, and compilation environment,
func() can be called in a separate process or in a separate thread of the same
process. It can also be called within the same thread as other sessions. It
is therefore important that the func function does not block.
Before the callback is called, catgen_listen() will have established the following prerequisites for the session:
-
Set up a catinfo search path using catgen_infopath.
-
Install the log dispatcher for the protocol, by calling
catlog_setdispatcher. For SSL sessions, ELS logging will be used. For DASP sessions, BoKS
logging will be used. If logging to a local file has been set up using catgen_initlogfile, this logging will take precedence.
-
Set the timeout for the session.
-
If the global certificate verification cache has been defined, use
catcert_setdb to install this cache.
-
Connect to the server, if one has been defined. If the connection fails, a
log event is generated and the session is terminated.
If no user-supplied callback has been defined, data is propagated between
the client and server until either side closes the connection or the
session times out.
The function returns 0 if successful, or a negative error code on error.
If the Agent fails to connect to the server, provided that a server has
been defined, the CATGEN_CONNFAIL event is logged.
If this function returns an error, the best action is probably to exit the
Agent. There is no graceful recovery.
The catgen_server function calls catgen_listen.
cat, catgen
catgen_getopt, catgen_parseargs, catgen_run,
catgen_server, catgen_newport