.. _close_connection: close_connection ------------------------------------------ This function disconnects the robot controller from the external PC. It safely terminates the established TCP/IP communication session. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool close_connection() { return _close_connection(_rbtCtrl); }; **Parameter** |br| None **Return** .. list-table:: :widths: 10 20 70 :header-rows: 1 * - **Value** - **Type** - **Description** * - 1 - int - Success — robot controller disconnected successfully. .. note:: When a connection ends (``close_connection``, loss of connection, or ``open_connection`` on an object that is already connected), every callback registered with a ``set_on_*`` function is unregistered, except those registered with ``set_on_disconnected``, ``set_on_monitoring_ctrl_io_ex`` (with DRCF_VERSION 3, the default), ``set_on_rt_monitoring_data`` and ``set_on_rt_log_alarm``, which stay registered. After each successful ``open_connection``, register the other callbacks again and call ``setup_monitoring_version`` again. ``open_connection`` on a connected object closes the existing connection first and prints "Already connected : ". After the connection has ended, call only ``open_connection``. **Example** .. code-block:: cpp drfl.close_connection(); This example safely closes the TCP/IP connection with the robot controller, ensuring all communication sessions are properly terminated.