# NNS_McsOpenStreamEx

## Syntax

      #include <nnsys/mcs.h>

      struct NNSMcsStreamInfo
      {
          DWORD   structBytes;
          DWORD   deviceType;
      };

      HANDLE NNS_McsOpenStreamEx(
                 USHORT            channel,
                 DWORD             flags,
                 NNSMcsStreamInfo* pStreamInfo);

## Arguments

`channel` | Value for identifying a stream. Specify in the range 0 to `0x3FFF`. The range of `0x4000` to `0x7FFF` is reserved for TWL-System applications. The range of `0x8000` to `0xFFFF` is reserved for the MCS system.
`flags` | Flags specified when stream is opened. (For details, see Description.)
`pStreamInfo` | Pointer to the structure storing supplemental information related to the opened stream.

## Return Values

If the stream is successfully opened, returns the stream's handle. If the process fails, returns `INVALID_HANDLE_VALUE`. Use `GetLastError` to get details about the error.

## Description

Opens a stream for Multiple Channel Stream. Streams are actually pipes that have attached message type names in the Win32 system, and the return value is a handle for one of these name-attached pipes. The function `NNS_McsOpenStream` opens a pipe with an attached message type name, and registers the value identifying the stream specified by the argument `channel` to the MCS server.

To read and write to the stream, use the Win32 API's `ReadFile(Ex)` and `WriteFile(Ex)` functions.

For the argument `flag`, specify 0 or the values shown below. This value is passed to the sixth argument (`dwFlagsAndAttributes`) in the Win32 API's `CreateFile` function.

`FILE_FLAG_OVERLAPPED` | Inputs/outputs asynchronously (overlapped I/O). For details, see the explanation of `CreateFile` in the Win32 API.

Sets the supplemental information related to the opened stream to be stored in the `NNSMcsStreamInfo` structure specified by `pStreamInfo`. Details about the `NNSMcsStreamInfo` structure members are described below.

`structBytes` | Size of the structure. Set `sizeof(NNSMcsStreamInfo)` before calling the function.
`deviceType` | Indicates the device type.

Here is a list of the device types that can be set in `deviceType`.

`NNS_MCS_DEVICE_TYPE_UNKNOWN` | Unknown device
`NNS_MCS_DEVICE_TYPE_NITRO_DEBUGGER` | IS-NITRO-EMULATOR
`NNS_MCS_DEVICE_TYPE_NITRO_UIC` | IS-NITRO-UIC
`NNS_MCS_DEVICE_TYPE_ENSATA` | Ensata
`NNS_MCS_DEVICE_TYPE_TWL` | IS-TWL-DEBUGGER Hardware

## See Also

`NNS_McsOpenStream`

## Revision History

2009/02/10 Corrected inappropriate device name (IS-TWL-EMULATOR changed to IS-TWL-DEBUGGER hardware).
2008/06/20 Changed NITRO-System to TWL-System.
2008/02/08 Added IS-TWL-EMULATOR to the device types.
2005/01/11 Added Description. Deleted IS-CGB-EMULATOR from the device types and added Ensata.
2004/10/08 Added a description of the `channel` argument.
2004/07/20 Initial version.

CONFIDENTIAL