You are here: SwitchKit® Development Environment Programmer’s Guide > 6 Handler Functions > sk_setLLCConnectionHandler()
Description
The sk_setLLCConnectionHandler() function installs a handler function that will be called any time the application's connection with the LLC is created or destroyed by the SwitchKit API. The connection is created each time the application successfully connects to the LLC. The connection is destroyed each time the application is disconnected from the LLC. Disconnection may occur for any number of reasons including, termination of the LLC, network problems, or failure of the application to call rcvAndDispatch() on a regular basis.
When an LLC switchover occurs, the LLC connection handler will be called twice:
• When the connection to the LLC is initially lost indicating that a connection has been destroyed
(state = SK_LLC_CONN_DESTROYED)
• When the connection to an LLC is established indicating that a connection has been created
(state = SK_LLC_CONN_CREATED).
This function is also available as skts_removeLLCConnectionHandler().
int sk_setLLCConnectionHandler( void *aTag, LLCHandlerFunc *anLLCHandlerFunc);
int skts_setLLCConnectionHandler( void *aTag,
LLCHandlerFunc *anLLCHandlerFunc);
Definition of LLC Connection Handler Functions
Syntax
void LLCHandlerFunc(int aConId, int aConState, void *aTag);
Parameters
The function parameters are shown in the table below.
Argument |
Description |
---|---|
aConId |
aConID is a connection identifier specified at connection creation time and used to indicate which LLC an application wishes to communicate with. |
aConState |
The new state of the LLC connection. Possible values are: SK_LLC_CONN_DESTROYED |
aTag |
A value to be passed into the LLC connection handler each time the LLC connection handler is called. This value is also used to reference the handler when attempting to remove a handler using sk_removeLLCConnectionHandler(). |
The function parameters are shown in the table below.
Argument |
Description |
---|---|
aTag |
A value to be passed into the LLC connection handler each time the LLC connection handler is called. This value is also used to reference the handler when attempting to remove a handler using sk_removeLLCConnectionHandler(). |
aHandlerFunc |
A pointer to a function that is designed to handle messages. |
Possible return values for this function:
SK_HANDLER_ALREADY_EXISTS |
A connection handler for this tag already exists. Please remove the old connection handler before setting new handler. |
SK_UNABLE_TO_OBTAIN_LOCK |
Error occurred obtaining a Mutex (Threadsafe library only.) |
OK |
Success |