private boolean isValidPkgLength(
            int attrLength, int bodyLength, int allowedLen, ProcessResult procResult) {
        // Not valid if the maximum limit is less than or equal to 0
        if (allowedLen < 0) {
            return true;
        }
        // Reserve space for attribute
        if (bodyLength + attrLength > allowedLen - SdkConsts.RESERVED_ATTRIBUTE_LENGTH) {
            String errMsg = String.format("OverMaxLen: attrLen(%d) + bodyLen(%d) > allowedLen(%d) - fixedLen(%d)",
                    attrLength, bodyLength, allowedLen, SdkConsts.RESERVED_ATTRIBUTE_LENGTH);
            if (tcpExceptCnt.shouldPrint()) {
                logger.warn(errMsg);
            }
            return procResult.setFailResult(ErrorCode.REPORT_INFO_EXCEED_MAX_LEN, errMsg);
        }
        return true;
    }
TCP Message Sender class

Used to define the TCP sender common methods
inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/sender/tcp/InLongTcpMsgSender.java