/// <summary> /// Send a message on the tunnel. /// </summary> protected void SendAnpMsg(AnpMsg m) { AnpTransport transfer = InternalAnpTunnel.GetTransport(); Debug.Assert(transfer.IsReceiving || transfer.DoneReceiving); Debug.Assert(!transfer.IsSending); transfer.SendMsg(m); while (transfer.IsSending) { transfer.DoXfer(); if (transfer.IsSending) { SelectSockets set = new SelectSockets(); InternalAnpTunnel.UpdateSelect(set); Block(set); } } }
/// <summary> /// Retrieve a message from the tunnel. /// </summary> protected AnpMsg GetAnpMsg() { AnpTransport transfer = InternalAnpTunnel.GetTransport(); Debug.Assert(transfer.IsReceiving || transfer.DoneReceiving); Debug.Assert(!transfer.IsSending); while (!transfer.DoneReceiving) { transfer.DoXfer(); if (!transfer.DoneReceiving) { SelectSockets set = new SelectSockets(); InternalAnpTunnel.UpdateSelect(set); Block(set); } } AnpMsg msg = transfer.GetRecv(); transfer.BeginRecv(); return(msg); }
/// <summary> /// Kill ktlstunnel. /// </summary> public void Terminate() { tunnel.Terminate(); transport = null; }
/// <summary> /// Close the connection to ktlstunnel. /// </summary> public void Disconnect() { tunnel.Disconnect(); transport = null; }
/// <summary> /// Create an AnpTransport when the tunnel is connected. /// </summary> public void CreateTransport() { transport = new AnpTransport(tunnel.EndTls()); transport.BeginRecv(); }