다음을 통해 공유


RIOSendEx function

The RIOSendEx function sends network data on a connected registered I/O TCP socket or a bound registered I/O UDP socket with additional options for use with the Winsock registered I/O extensions.

Syntax

BOOL  RIOSendEx(
  _In_ RIO_RQ   SocketQueue,
  _In_ PRIO_BUF pData,
  _In_ ULONG    DataBufferCount,
  _In_ PRIO_BUF pLocalAddress,
  _In_ PRIO_BUF pRemoteAddress,
  _In_ PRIO_BUF pControlContext,
  _In_ PRIO_BUF pFlags,
  _In_ DWORD    Flags,
  _In_ PVOID    RequestContext
);

Parameters

  • SocketQueue [in]
    A descriptor that identifies a connected registered I/O TCP socket or a bound registered I/O UDP socket.

  • pData [in]
    A buffer segment from a registered buffer from which to send data. The RIO_BUF structure pointed to by this parameter can represent a portion of a registered buffer or a complete registered buffer.

    This parameter may be NULL for a bound registered I/O UDP socket if the application does not need to send a data payload in the UDP datagram.

  • DataBufferCount [in]
    A data buffer count parameter that indicates if data is to be sent in the buffer pointed to by the pData parameter.

    This parameter should be set to zero if the pData is NULL. Otherwise, this parameter should be set to 1.

  • pLocalAddress [in]
    This parameter is reserved and must be NULL.

  • pRemoteAddress [in]
    A buffer segment from a registered buffer that on input holds the remote address to which the network data is to be sent.

    This parameter may be NULL if the socket is connected.

  • pControlContext [in]
    A buffer slice that on completion will hold additional control information about the send operation.

    This parameter may be NULL if the application does not want to receive the additional control information.

  • pFlags [in]
    A buffer slice that on completion will hold additional information about the set of flags for the send operation.

    This parameter may be NULL if the application does not want to receive the additional flags information.

  • Flags [in]
    A set of flags that modify the behavior of the RIOSendEx function.

    The Flags parameter can contain a combination of the following options defined in the Mswsockdef.h header file:

    Flag Meaning
    RIO_MSG_COMMIT_ONLY

    Previous requests added with RIO_MSG_DEFER flag will be committed.

    When the RIO_MSG_COMMIT_ONLY flag is set, no other flags may be specified. When the RIO_MSG_COMMIT_ONLY flag is set, the pData, pLocalAddress, pRemoteAddress, pControlContext, pFlags, and RequestContext parameters must be NULL and the DataBufferCount parameter must be zero.

    This flag would normally be used occasionally after a number of requests were issued with the RIO_MSG_DEFER flag set. This eliminates the need when using the RIO_MSG_DEFER flag to make the last request without the RIO_MSG_DEFER flag, which causes the last request to complete much slower than other requests.

    Unlike other calls to the RIOSendEx function, when the RIO_MSG_COMMIT_ONLY flag is set calls to the RIOSendEx function do not need to be serialized. For a single RIO_RQ, the RIOSendEx function can be called with RIO_MSG_COMMIT_ONLY on one thread while calling the RIOSendEx function on another thread.

    RIO_MSG_DONT_NOTIFY

    The request should not trigger the RIONotify function when request completion is inserted into its completion queue.

    RIO_MSG_DEFER

    The request does not need to be executed immediately. This will insert the request into the request queue, but it may or may not trigger the execution of the request.

    Sending data may be delayed until a send request is made on the RIO_RQ passed in the SocketQueue parameter without the RIO_MSG_DEFER flag set. To trigger execution for all sends in a send queue, call the RIOSend or RIOSendEx function without the RIO_MSG_DEFER flag set.

    Note  The send request is charged against the outstanding I/O capacity on the RIO_RQ passed in the SocketQueue parameter regardless of whether RIO_MSG_DEFER is set.
     

     

  • RequestContext [in]
    The request context to associate with this send operation.

Return value

If no error occurs, the RIOSendEx function returns TRUE. In this case, the send operation is successfully initiated and the completion will have already been queued or the operation has been successfully initiated and the completion will be queued at a later time.

A value of FALSE indicates the function failed, the operation was not successfully initiated and no completion indication will be queued. A specific error code can be retrieved by calling the WSAGetLastError function.

Return code Description
WSAEFAULT

The system detected an invalid pointer address in attempting to use a pointer argument in a call. This error is returned if a buffer identifier is deregistered or a buffer is freed for any of the RIO_BUF structures passed in parameters before the operation is queued or invoked.

WSAEINVAL

An invalid parameter was passed to the function.

This error is returned if the SocketQueue parameter is not valid, the Flags parameter contains an value not valid for a send operation, or the integrity of the completion queue has been compromised. This error can also be returned for other issues with parameters.

WSAENOBUFS

Sufficient memory could not be allocated. This error is returned if the I/O completion queue associated with the SocketQueue parameter is full or the I/O completion queue was created with zero send entries.

WSA_IO_PENDING

The operation has been successfully initiated and the completion will be queued at a later time.

 

Remarks

An application can use the RIOSendEx function to send network data from any buffer completely contained within a single registered buffer. The Offset and Length members of the RIO_BUF structure pointed to by the pData parameter determine the network data to be sent from the buffer.

The buffer associated with a send operation should not be used concurrently with another send operation. The buffer, and buffer registration, must remain valid for the duration of a send operation. This means that you should not pass the same PRIO_BUF to a RIOSend(Ex) request when one is already pending. Only after an in-flight RIOSend(Ex) request is complete should you re-use the same PRIO_BUF (either with the same offset or with a different offset and length).

The pLocalAddress parameter can be used to retrieve the local address from which the data was sent. The pRemoteAddress parameter can be used to retrieve the remote address to which the data was sent. The local and remote addresses are returned as SOCKADDR_INET structures. As a result, the Length member of the RIO_BUF pointed to by pLocalAddress or pRemoteAddress parameters should be equal or greater than the size of a SOCKADDR_INET structure.

The following table summarizes the various uses of control data available for use with the control information in the pControlContext member.

Protocol cmsg_level cmsg_type Description
IPv4 IPPROTO_IP IP_PKTINFO

Specifies/receives packet information.

For more information, see the IPPROTO_IP Socket Options for the IP_PKTINFO socket option.

IPv6 IPPROTO_IPV6 IPV6_DSTOPTS

Specifies/receives destination options.

IPv6 IPPROTO_IPV6 IPV6_HOPLIMIT

Specifies/receives hop limit.

For more information, see the IPPROTO_IPV6 Socket Options for the IPV6_HOPLIMIT socket option.

IPv6 IPPROTO_IPV6 IPV6_HOPOPTS

Specifies/receives hop-by-hop options.

IPv6 IPPROTO_IPV6 IPV6_NEXTHOP

Specifies next-hop address.

IPv6 IPPROTO_IPV6 IPV6_PKTINFO

Specifies/receives packet information.

For more information, see the IPPROTO_IPV6 Socket Options for the IPV6_PKTINFO socket option.

IPv6 IPPROTO_IPV6 IPV6_RTHDR

Specifies/receives routing header.

 

Control data is made up of one or more control data objects, each beginning with a WSACMSGHDR structure, defined as the following:


struct wsacmsghdr {
  UINT        cmsg_len;
  INT         cmsg_level;
  INT         cmsg_type;
  /* followed by UCHAR cmsg_data[] */
} WSACMSGHDR;

The members of the WSACMSGHDR structure are as follows:

Term Description

cmsg_len

The number of bytes of data starting from the beginning of the WSACMSGHDR to the end of data (excluding padding bytes that may follow data).

cmsg_level

The protocol that originated the control information.

cmsg_type

The protocol-specific type of control information.

 

The Flags parameter can be used to influence the behavior of the RIOSendEx function beyond the options specified for the associated socket. The behavior of this function is determined by a combination of any socket options set on the socket associated with the SocketQueue parameter and the values specified in the Flags parameter.

Note  The function pointer to the RIOSendEx function must be obtained at run time by making a call to the WSAIoctl function with the SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER opcode specified. The input buffer passed to the WSAIoctl function must contain WSAID_MULTIPLE_RIO, a globally unique identifier (GUID) whose value identifies the Winsock registered I/O extension functions. On success, the output returned by the WSAIoctl function contains a pointer to the RIO_EXTENSION_FUNCTION_TABLE structure that contains pointers to the Winsock registered I/O extension functions. The SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER IOCTL is defined in the Ws2def.h header file. The WSAID_MULTIPLE_RIO GUID is defined in the Mswsock.h header file.

 

Windows Phone 8: This function is supported for Windows Phone Store apps on Windows Phone 8 and later.

Windows 8.1 and Windows Server 2012 R2: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.

Requirements

Minimum supported client

Windows 8.1, Windows 8 [desktop apps | UWP apps]

Minimum supported server

Windows Server 2012 [desktop apps | UWP apps]

Minimum supported phone

Windows Phone 8

Header

Mswsock.h

Library

Mswsock.lib

DLL

Mswsock.dll

See also

RIO_BUF

RIO_EXTENSION_FUNCTION_TABLE

RIO_RQ

RIONotify

RIOSend

WSAIoctl

WSAMSG