Close the given channel, allowing to provide a user defined pointer to be passed to the callback.
Free all resources allocated by the channel and tries to closes it if is opened. Once you have called this function, the channel will no longer be available until it is created again and the function will notify vortex session (the connection associated with this channel) to remove this channel reference from it.
In some cases the channel close request could be denied by the remote peer. This may happen if other side have something remaining to be sent while you are trying to close. This means the function will block the caller until the channel close process reply is receive.
It is possible to avoid getting blocked on the channel close process by setting the on_close_notification which is called at the end of the process, notifying if channel was closed or not.
In both models, making the blocking close operation or the non-blocking one, using the on_close_notification, if channel is closed, channel resources will be deallocated so channel pointer provided will no longer be pointing to a valid channel.
Another thing about channel close process to keep in mind it that close handler defined at vortex_channel_new or at vortex_profiles_register is NOT executed when vortex_channel_close is called. Those handlers are actually executed when your channel receive a close indication. This also means this function sends a close indication to remote peer so, if remote peer is also a vortex enabled one and have a close handler defined, then they will be executed.
There are an exception to keep in mind. Channel 0 can not be closed using this function. This channel is hard-wired to the actual session. Channel 0 is closed on session close (vortex_connection_close). If you still want to close channel 0 call vortex_connection_close instead.
During the on_closed handler execution, if defined, you can still get access to the channel being closed. This is provided because you may be interesting on getting the channel status, etc. After on_closed is executed and finished, the channel resources are deallocated.