You are here: SwitchKit Programmer’s Guide > 3 Channel Management > sk_returnChannel()
Description
Your application should call sk_returnChannel() when a process is finished with a channel. This function returns the channel to the pool of free channels, and stops the process from receiving messages for that channel.
To prevent future messages from coming to the application module unexpectedly, the function sk_returnChannel() must be called for channels explicitly assigned from sk_requestOutseizedChannel() and implicitly assigned through sk_watchChannelGroup().
Alternatively, if the environment variable, SK_AUTO_RETURN_CHANNELS is set, any time the message XL_ChannelReleased is sent from the switch, the channel is returned automatically. We recommend using SK_AUTO_RETURN_CHANNELS because it simplifies application development. It also prevents a possible race condition when a XL_ChannelReleased message is immediately followed by a XL_RequestForService, before the application has been able to return the channel. To prevent an application from returning channels allocated to other applications, set the environment variable, SK_RETURN_CHANNEL_BY_OWNER_ONLY.
This function is also available as sk_returnChannelOnConnection() and skts_returnChannelOnConnection().
Syntax
int sk_returnChannel(int aSpan, int aChannel);
int sk_returnChannelOnConnection(int aSpan, int aChannel, int aConID);
int skts_returnChannel(int aSpan, int aChannel, int aConID );
Parameters
The function parameters are shown in the table below.
Argument |
Description |
---|---|
aSpan |
Identifies the span number. |
aChannel |
Identifies the channel number. |
aConID |
aConID is a connection identifier specified at connection creation time and used to indicate which LLC an application wishes to communicate with. |
Possible return values for this function:
SK_LOST_LLC |
This return value indicates that your application lost contact with the LLC. |
SK_NOT_ |
This return value indicates that the channel is not allocated to this application. |