# NNS_McsRegisterRecvCallback

## C Specification

      #include <nnsys/mcs.h>

      void NNS_McsRegisterRecvCallback(
      NNSMcsRecvCBInfo*   pInfo,
      u16             channel ,
      NNSMcsRecvCallback  cbFunc,
      u32                 userData);

## Arguments

pInfo | Pointer to the structure holding the callback function's information.
channel | Value for identifying a stream. You can specify in the range 0-0x3FFF. 0x4000-0x7FFF is reserved for NITRO-System applications. 0x8000-0xFFFF is reserved for the MCS system.
cbFunc | The callback function to register.
userData | User's optional value.

## Return Values

None.

## Description

Registers the function to be called back when data is received

Type `NNSMcsRecvCallback` of `cbFunc` is defined as the following. The definition of the function to register is shown below.

>     typedef void (*NNSMcsRecvCallback)(
>     const void* recv,
>     u32         recvSize,
>     u32         userData,
>     u32         offset,
>     u32         totalSize);

recv | Pointer to the buffer that stores a portion or all of the received data.
recvSize | Size of the data that is stored in the buffer indicated by `recv`.
userData | A value specified with the argument `userData` of `NNS_McsRegisterRecvCallback`.
offset | 0 if all of the received data is stored in the buffer that is indicated by `recv`. Offset location that uses 0, which is for all of the received data, as a reference if a portion of the received data is stored.
totalSize | Total size of the received data.

If the received data is large, callback function is called multiple times. When it happens, the buffer indicated by recv stores a part of the data, and in offset the offset value from the entire data that is stored. In `totalSize`, the total size of the received data is always used.

Do not send or receive data from inside this registered callback function. In addition, do not perform a wait-for-interrupt loop, since interrupts are sometimes prohibited.

## See Also

`NNS_McsRegisterStreamRecvBuffer`, `NNS_McsUnregisterRecvResource`

## Revision History

11/29/2004 Added the description of callback function
10/08/2004 Added a description of the channel argument. Added `NNS_McsUnregisterRecvResource` in See Also.
08/26/2004 Changed the argument channel type.
06/01/2004 Initial version.