How to close notification socket?

when i call confd_notifications_connect2 to parse notificaitons, how to close the socket when parse done?

Typical usage is that you connect and stay connected - otherwise you may/will miss notifications. But if you don’t want to stay connected, you can just use close() on the socket.

close() seems not close the user session, i am try to use cdb_end_session(socket); it works.

can i use close() and cdb_end_session() together?

Is this related to your previous question about closing a socket connected with confd_notifications_connect2()? Anyway,

  • confd_notifications_connect2() is a function in the event notifications API, documented in the confd_lib_events(3) manual page.
  • cdb_end_session() is a function in the CDB API, documented in the confd_lib_cdb(3) manual page.
  • Neither the event notifications API nor the CDB API has any concept of starting or stopping user sessions.
  • You can most certainly not use the CDB API function cdb_end_session() with a socket for event notifications.
  • Using close() on an event notification socket will close the connection and discard the subscriptions requested via confd_notifications_connect() or confd_notifications_connect2().
  • Using close() on a CDB socket will close the connection and end the session (if any) for a CDB_DATA_SOCKET, or discard the subscriptions (if any) for a CDB_SUBSCRIPTION_SOCKET. However the documentation says to use cdb_close() rather than close() for this purpose.
  • Using cdb_end_session() on a CDB_DATA_SOCKET will end the session (if any), but not close the connection - as the documentation says, this is mostly useful if you want to reuse the connection for another session.