/// <summary>Sends an open reference request to the remote peer and creates the associated channel.</summary> void SendOpenReference(int Reference) { int RT = (int)MessageType.OpenReference; byte[] data = new byte[8] { (byte)(RT % 256), (byte)(RT / 256 % 256), (byte)(RT / 65536 % 256), (byte)(RT / 16777216 % 256), (byte)(Reference % 256), (byte)(Reference / 256 % 256), (byte)(Reference / 65536 % 256), (byte)(Reference / 16777216 % 256) }; byte[] IV = ControlChannel.SendReceive(1, data, 8); CreateChannel(Reference, IV); }
/// <summary>Send a handshake to check the channel.</summary> void SendHandshake() { int HT = (int)MessageType.Handshake; byte[] Hdata = new byte[4] { (byte)(HT % 256), (byte)(HT / 256 % 256), (byte)(HT / 65536 % 256), (byte)(HT / 16777216 % 256) }; byte[] Reply = ControlChannel.SendReceive(1, Hdata, 4); if (!((Reply[0] == Hdata[0]) & (Reply[1] == Hdata[1]) & (Reply[2] == Hdata[2]) & (Reply[3] == Hdata[3]))) { throw new System.Net.ProtocolViolationException("Handshake failed"); } }