int open_connection (const String &config, const String &display) { SocketAddress addr (scim_get_default_panel_socket_address (display)); if (m_socket.is_connected ()) close_connection (); bool ret; int count = 0; // Try three times. while (1) { if ((ret = m_socket.connect (addr)) == false) { scim_usleep (100000); launch_panel (config, display); for (int i = 0; i < 200; ++i) { if (m_socket.connect (addr)) { ret = true; break; } scim_usleep (100000); } } if (ret && scim_socket_open_connection (m_socket_magic_key, String ("FrontEnd"), String ("Panel"), m_socket, m_socket_timeout)) break; m_socket.close (); if (count++ >= 3) break; scim_usleep (100000); } return m_socket.get_id (); }
void close_connection () { m_socket.close (); m_socket_magic_key = 0; }