K2Informatics.Erlnet.OtpInputStream.read1 C# (CSharp) Method

read1() public method

public read1 ( ) : int
return int
        public int read1()
        {
            int i;
            i = base.ReadByte();

            if (i < 0)
            {
                throw new OtpErlangDecodeException("Cannot read from input stream");
            }

            return i;
        }

Usage Example

Ejemplo n.º 1
0
        protected void recvChallengeAck(int our_challenge)
        {
            byte[] her_digest = new byte[16];
            try
            {
                byte[] buf = read2BytePackage();
                OtpInputStream ibuf = new OtpInputStream(buf, 0);
                int tag = ibuf.read1();
                if (tag != ChallengeAck)
                {
                    throw new IOException("Handshake protocol error");
                }
                ibuf.readN(her_digest);
                byte[] our_digest = genDigest(our_challenge, self.Cookie);
                if (!digests_equals(her_digest, our_digest))
                {
                    throw new OtpAuthException("Peer authentication error.");
                }
            }
            catch (OtpErlangDecodeException)
            {
                throw new IOException("Handshake failed - not enough data");
            }
            catch (Exception)
            {
                throw new OtpAuthException("Peer authentication error.");
            }

            if (traceLevel >= handshakeThreshold)
            {
                log.Debug("<- " + "HANDSHAKE recvChallengeAck" + " from="
                             + peer.Node + " digest=" + hex(her_digest) + " local=" + self);
            }
        }
All Usage Examples Of K2Informatics.Erlnet.OtpInputStream::read1