protected void sendHandshakeRequest() { int tokenSize = sessionToken.Length; int messageSize = 0; messageSize += 8; // sessionIdSize messageSize += 2; // tokenLengthSize messageSize += tokenSize; // messageSize EzyByteBuffer buffer = EzyByteBuffer.allocate(1 + 2 + messageSize); byte header = 0; header |= 1 << 5; buffer.put(header); buffer.putShort((short)messageSize); buffer.putLong(sessionId); buffer.putShort((short)tokenSize); buffer.put(EzyStrings.getBytes(sessionToken)); buffer.flip(); byte[] bytes = buffer.getRemainBytes(); datagramChannel.Send(bytes, bytes.Length); }