private NodeGreetingMessage ReadGreeting() { var read = _streamSocket.Read(_singleByteBuffer, 0, 1); if (read == 0) { throw new RedFoxProtocolException("Error receiving greeting message from remote machine"); } var headerLength = _singleByteBuffer[0]; var header = new byte[headerLength]; var offset = 0; while (headerLength - offset > 0) { read = _streamSocket.Read(header, offset, headerLength - offset); if (read == 0) { throw new RedFoxProtocolException("Error receiving greeting message from remote machine"); } offset += read; } return(NodeGreetingMessage.DeserializeWithoutLength(header)); }
private static byte[] ReadHeader(IStreamSocket stream) { var header = new byte[6]; var offset = 0; while (offset < header.Length) { var read = stream.Read(header, offset, header.Length - offset); if (read == 0) { throw new EndOfStreamException(); } offset += read; } return(header); }
private static byte[] ReadBody(IStreamSocket stream, int length) { var rawMessage = new byte[length]; var offset = 0; while (offset < length) { var read = stream.Read(rawMessage, offset, rawMessage.Length - offset); if (read == 0) { throw new EndOfStreamException(); } offset += read; } return(rawMessage); }
private static byte[] ReadHeader(IStreamSocket stream) { var header = new byte[6]; var offset = 0; while (offset < header.Length) { var read = stream.Read(header, offset, header.Length - offset); if (read == 0) throw new EndOfStreamException(); offset += read; } return header; }
private static byte[] ReadBody(IStreamSocket stream, int length) { var rawMessage = new byte[length]; var offset = 0; while (offset < length) { var read = stream.Read(rawMessage, offset, rawMessage.Length - offset); if (read == 0) throw new EndOfStreamException(); offset += read; } return rawMessage; }