/// <summary> /// Connect the management logic to OpenVPN /// </summary> protected bool ConnectLogic() { m_ovpnMLogic.reset(); for (int i = 0; i < 8; ++i) { try { System.Threading.Thread.Sleep(500); m_ovpnMLogic.connect(); return(true); } catch (System.Net.Sockets.SocketException ex) { m_logs.logDebugLine(1, "Could not establish connection " + "to management interface:" + ex.Message); if (m_state.ConnectionState != VPNConnectionState.Initializing) { return(false); } if (i != 8) { m_logs.logDebugLine(1, "Trying again in a second"); System.Threading.Thread.Sleep(500); } } } if (m_state.ConnectionState != VPNConnectionState.Initializing) { return(false); } m_logs.logDebugLine(1, "Could not establish connection, abording"); m_state.ConnectionState = VPNConnectionState.Running; Disconnect(); while (m_state.ConnectionState != VPNConnectionState.Stopped) { Thread.Sleep(200); } m_state.ChangeState(VPNConnectionState.Error); return(false); }
/// <summary> /// Connect the management logic to OpenVPN /// </summary> protected bool ConnectLogic() { m_ovpnMLogic.reset(); for (int i = 0; i < 8; ++i) { try { System.Threading.Thread.Sleep(500); m_ovpnMLogic.connect(); return(true); } catch (System.Net.Sockets.SocketException ex) { if (m_state.ConnectionState != VPNConnectionState.Initializing) { return(false); } if (i != 8) { System.Threading.Thread.Sleep(500); } } } if (m_state.ConnectionState != VPNConnectionState.Initializing) { return(false); } m_state.ConnectionState = VPNConnectionState.Running; Disconnect(); while (m_state.ConnectionState != VPNConnectionState.Stopped) { Thread.Sleep(200); } m_state.ChangeState(VPNConnectionState.Error); return(false); }