# GetMsgBody

### int GetMsgBody(int lMsgId, byte\[] pnMsgBuff)

이함수는 수신된 SECS 메시지의 전체 바디(Body) 데이터를 가공되지 않은 바이너리(Raw Binary) 형태로 한꺼번에 읽어올 때 사용합니다. 특정 아이템을 개별적으로 파싱하기 전에 메시지 전체 구조를 바이트 배열로 백업하거나, 외부 로그 분석기 등에 전달하기 위한 용도로 매우 유용합니다.

Parameters

<table data-header-hidden><thead><tr><th width="202" valign="top"></th><th width="95" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">lMsgId</td><td valign="top">int</td><td valign="top">수신한 Message의 ID</td></tr><tr><td valign="top">pnMsgBuff</td><td valign="top">byte[]</td><td valign="top">읽어올 Message를 저장할 Message Buffer, byte배열</td></tr></tbody></table>

```csharp
// 1. 메시지 바디를 담을 충분한 크기의 버퍼 준비
    // (메시지 크기를 미리 알 수 있다면 해당 크기만큼, 모른다면 최대 예상치 설정)
    byte[] msgBuffer = new byte[4096]; 

    // 2. GetMsgBody 호출
    // 반환값(nReadSize)은 실제로 읽어온 바이트 수를 의미합니다.
    int nReadSize = m_gem.GetMsgBody(lMsgId, msgBuffer);

    if (nReadSize >= 0)
    {
        Console.WriteLine($"메시지 바디 추출 성공. 크기: {nReadSize} bytes");
        
        // 추출된 바이너리 데이터를 16진수로 출력하는 예시
        string hex = BitConverter.ToString(msgBuffer, 0, nReadSize);
        Console.WriteLine($"Raw Data: {hex}");
    }
    else
    {
        Console.WriteLine($"메시지 바디 추출 실패. 에러 코드: {nReadSize}");
    }
```


---

# 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/getmsgbody.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.
