protected override void Run() { // Connect the tunnel. InternalAnpTunnel = new AnpTunnel(Host, Port); Tunnel tunnel = InternalAnpTunnel.GetTunnel(); InternalAnpTunnel.BeginConnect(ReconnectHost, ReconnectPort); while (true) { SelectSockets set = new SelectSockets(); set.Timeout = 100; tunnel.CheckTls(); set.AddRead(tunnel.Sock); Block(set); if (set.ReadSockets.Contains(tunnel.Sock)) { InternalAnpTunnel.CreateTransport(); break; } } // Handle the tunnel. OnTunnelConnected(); }
/// <summary> /// If the tunnel is connected, a new AnpTransport is created and the /// method returns true. Otherwise, the method returns false. /// </summary> public bool CheckConnect() { SelectSockets select = new SelectSockets(); select.Timeout = 0; select.AddRead(tunnel.Sock); tunnel.CheckTls(); select.Select(); if (select.ReadSockets.Contains(tunnel.Sock)) { CreateTransport(); return(true); } return(false); }