public override void ReadFromSocket(Socket socket) { Clear(); string xLine = socket.ReadLn(); while (xLine.Length > 3 && xLine[3] == ' ') { if (Code == 0) { Code = Int32.Parse(xLine.Substring(0, 3)); } Text.Add(xLine.Substring(4)); xLine = socket.ReadLn(); } Text.Add(xLine.Substring(4)); }
private int ChunkRead(byte[] buffer, int offset, int count) { if (_endStream) { return(0); } int result = 0; while (result < count) { if (_chunkSize <= 0) { if (!int.TryParse(_socket.ReadLn(), out _chunkSize) || _chunkSize <= 0) { _endStream = true; break; } } int bytesToRead = count - result <= _chunkSize ? count - result : _chunkSize; byte[] temp = null; try { temp = _socket.ReadBytes(bytesToRead); } catch (NotEnoughDataInBufferException) { temp = _socket.ReadBytes(_socket.mInputBuffer.Size); } temp.CopyTo(buffer, offset); offset += temp.Length; result += temp.Length; _chunkSize -= temp.Length; if (temp.Length == 0) { break; } } return(result); }