Пример #1
0
        public string Read()
        {
            int messageByteLength = int.Parse(stream.ReadBytes(6));

            stream.ReadBytes(1); // skip the colon
            string message = stream.ReadBytes(messageByteLength);

            if (EndIdentifier.Matches(message))
            {
                IsEnd = true;
                socket.Close();
                return(null);
            }
            return(message);
        }
Пример #2
0
        public string Read()
        {
            string lengthString = string.Empty;

            while (true)
            {
                var lengthCharacter = stream.ReadBytes(1);
                if (lengthCharacter == ":")
                {
                    break;
                }
                lengthString += lengthCharacter;
            }
            int    messageByteLength = int.Parse(lengthString);
            string message           = stream.ReadBytes(messageByteLength);

            if (EndIdentifier.Matches(message))
            {
                IsEnd = true;
                socket.Close();
                return(null);
            }
            return(message);
        }
Пример #3
0
 public void Close()
 {
     socket.Close();
 }