> For the complete documentation index, see [llms.txt](https://nviasoft.gitbook.io/nviasoft-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getmsglength.md).

# GetMsgLength

### int GetMsgLength(int lMsgId)

GetMsgInfo 함수는 **수신된** SECS 메시지의 헤더 정보를 추출할 때 사용합니다. 메시지의 Stream(S), Function(F), Wait Bit(W) 그리고 \*\*전체 메시지 길이(Length)\*\*를 한 번에 확인할 수 있어, 메시지 수신 후 어떤 로직으로 분기할지 결정하는 가장 기초적이면서도 중요한 함수입니다.

{% hint style="info" %}

* 메모리 할당의 근거: `GetMsgBody` 등을 통해 데이터를 따로 복사해올 때, 미리 어느 정도의 메모리 공간이 필요한지 계산하는 용도로 자주 사용됩니다.
* 성능 최적화: 단순히 길이를 읽어오는 함수이므로 부하가 매우 적습니다. 루프 내에서 메시지 유효성을 빠르게 체크하는 용도로 적합합니다.
* 만약 S1F1을 조회했을경우 0을 리턴합니다. S1F1은 HeadOnly이기 때문입니다.
  {% endhint %}

Parameters

<table data-header-hidden><thead><tr><th></th><th width="157"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>lMsgId</td><td>int</td><td>길이를 조회할 대상 메시지의 고유 ID</td></tr></tbody></table>

```csharp
void PrintMessageSize(int lMsgId)
{
    // 메시지 전체 길이 확인
    int msgLength = m_gem.GetMsgLength(lMsgId);

    if (msgLength > 0)
    {
        Console.WriteLine($"[MsgID: {lMsgId}] 의 총 크기는 {msgLength} 바이트입니다.");
    }
    else
    {
        Console.WriteLine("메시지 길이를 가져오는 데 실패했습니다.");
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getmsglength.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
