SIO_IDEAL_SEND_BACKLOG_CHANGE Control Code
The SIO_IDEAL_SEND_BACKLOG_CHANGE control code notifies an application when the ideal send backlog (ISB) value changes for the connection.
To perform this operation, call the WSAIoctl or WSPIoctl function with the following parameters.
int WSAIoctl( (socket) s, // descriptor identifying a socket SIO_IDEAL_SEND_BACKLOG_CHANGE, // dwIoControlCode NULL, // lpvInBuffer 0, // cbInBuffer NULL, // output buffer 0, // size of output buffer (LPDWORD) lpcbBytesReturned, // number of bytes returned (LPWSAOVERLAPPED) lpOverlapped, // OVERLAPPED structure (LPWSAOVERLAPPED_COMPLETION_ROUTINE) lpCompletionRoutine, // completion routine );
int WSPIoctl( (socket) s, // descriptor identifying a socket SIO_IDEAL_SEND_BACKLOG_CHANGE, // dwIoControlCode NULL, // lpvInBuffer 0, // cbInBuffer NULL, // output buffer 0, // size of output buffer (LPDWORD) lpcbBytesReturned, // number of bytes returned (LPWSAOVERLAPPED) lpOverlapped, // OVERLAPPED structure (LPWSAOVERLAPPED_COMPLETION_ROUTINE) lpCompletionRoutine, // completion routine (LPWSATHREADID) lpThreadId, // a WSATHREADID structure (LPINT) lpErrno // a pointer to the error code. );
A descriptor identifying a socket.
The control code for the operation. Use SIO_IDEAL_SEND_BACKLOG_CHANGE for this operation.
A pointer to the input buffer. This parameter is unused for this operation.
The size, in bytes, of the input buffer.This parameter is unused for this operation.
A pointer to the output buffer. This parameter is unused for this operation.
The size, in bytes, of the output buffer. This parameter must be set to zero.
A pointer to a variable that receives the size, in bytes, of the data stored in the output buffer. This returned parameter points to a DWORD value of zero for this operation, since there is no output.
A pointer to a WSAOVERLAPPED structure.
If socket s was created without the overlapped attribute, the lpOverlapped parameter is ignored.
If s was opened with the overlapped attribute and the lpOverlapped parameter is not NULL, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped parameter must point to a valid WSAOVERLAPPED structure.
For overlapped operations, the WSAIoctl or WSPIoctl function returns immediately, and the appropriate completion method is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.
Type: _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE
A pointer to the completion routine called when the operation has been completed (ignored for non-overlapped sockets).
A pointer to a WSATHREADID structure to be used by the provider in a subsequent call to WPUQueueApc. The provider should store the referenced WSATHREADID structure (not the pointer to same) until after the WPUQueueApc function returns.
Note This parameter applies only to the WSPIoctl function.
A pointer to the error code.
Note This parameter applies only to the WSPIoctl function.
If the operation completes successfully, the WSAIoctl or WSPIoctl function returns zero.
|WSA_IO_PENDING||An overlapped operation was successfully initiated and completion will be indicated at a later time.|
|WSA_OPERATION_ABORTED||An overlapped operation was canceled due to the closure of the socket or the execution of the SIO_FLUSH IOCTL command.|
|WSAEFAULT||The lpOverlapped or lpCompletionRoutine parameter is not totally contained in a valid part of the user address space.|
|WSAEINPROGRESS||The function is invoked when a callback is in progress.|
|WSAEINTR||A blocking operation was interrupted.|
|WSAEINVAL||The dwIoControlCode parameter is not a valid command, or a specified input parameter is not acceptable, or the command is not applicable to the type of socket specified. This error is returned if the cbOutBuffer parameter is not zero.|
|WSAENETDOWN||The network subsystem has failed.|
|WSAENOPROTOOPT||The socket option is not supported on the specified protocol.|
|WSAENOTCONN||The socket s is not connected.|
|WSAENOTSOCK||The descriptor s is not a socket.|
|WSAEOPNOTSUPP||The specified IOCTL command is not supported. This error is returned if the SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL is not supported by the transport provider. This error is also returned when an attempt to use the SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL is made on a datagram socket.|
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL is supported on Windows Server 2008, Windows Vista with Service Pack 1 (SP1), and later versions of the operating system.
When sending data over a TCP connection using Windows sockets, it is important to keep a sufficient amount of data outstanding (sent but not acknowledged yet) in TCP in order to achieve the highest throughput. The ideal value for the amount of data outstanding to achieve the best throughput for the TCP connection is called the ideal send backlog (ISB) size. The ISB value is a function of the bandwidth-delay product of the TCP connection and the receiver's advertised receive window (and partly the amount of congestion in the network).
The ISB value per connection is available from the TCP protocol implementation in Windows Server 2008, Windows Vista with SP1, and later versions of the operating system. The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL can be used by an application to get a notification when the ISB value changes dynamically for a connection.
On Windows Server 2008, Windows Vista with SP1, and later versions of the operating system, the SIO_IDEAL_SEND_BACKLOG_CHANGE and SIO_IDEAL_SEND_BACKLOG_QUERY IOCTLs are supported on stream-oriented sockets that are in a connected state.
The range for the ISB value for a TCP connection can theoretically vary from 0 to a maximum of 16 megabytes.
See the SIO_IDEAL_SEND_BACKLOG_QUERY IOCTL reference page for typical usage of the ISB mechanism for achieving better throughput over high bandwidth-delay product connections.
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL is allowed only on a stream socket that is in the connected state. Otherwise the WSAIoctl or WSPIoctl function will fail with WSAENOTCONN.
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL uses no input or output buffers and pends or blocks until an ISB change occurs on the underlying connection. When this IOCTL is completed, a Winsock application can use the SIO_IDEAL_SEND_BACKLOG_QUERY IOCTL to retrieve the new ISB value on the connection.
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL does not support non-blocking mode. An application is allowed to issue this IOCTL on a non-blocking socket, but the IOCTL will simply block or pend until the ISB value changes.
If both lpOverlapped and lpCompletionRoutine parameters are NULL, the socket in this function will be treated as a non-overlapped socket. For a non-overlapped socket, lpOverlapped and lpCompletionRoutine parameters are ignored, except that the function can block if socket s is in blocking mode. If socket s is in non-blocking mode, this function will still block since this particular IOCTL does not support non-blocking mode.
For overlapped sockets, operations that cannot be completed immediately will be initiated, and completion will be indicated at a later time.
Any IOCTL may block indefinitely, depending on the service provider's implementation. If the application cannot tolerate blocking in a WSAIoctl or WSPIoctl function call, overlapped I/O would be advised for IOCTLs that are especially likely to block.
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL provides a notification and is expected to block or pend until the ISB value changes. So it would commonly be called asynchronously with the lpOverlapped parameter set to a valid WSAOVERLAPPED structure.
The SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL can fail with WSAEINTR or WSA_OPERATION_ABORTED under the following cases:
- The TCP connection is gracefully disconnected in the send direction. This can occur as a result of a call to shutdown function with the how parameter set to SD_SEND, a call to the DisconnectEx function, or a call to the TransmitFile or TransmitPackets function with dwFlags parameter set to TF_DISCONNECT or TF_REUSE.
- The TCP connection has been reset or aborted.
- The application issues a SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL when there is already a pended notification request. Only one one pended SIO_IDEAL_SEND_BACKLOG_CHANGE request is allowed at a time.
- The request is canceled by the I/O Manager.
- The socket is closed.
Two inline wrapper functions for these IOCTLs are defined in the Ws2tcpip.h header file. It is recommended that these inline functions be used instead of using the SIO_IDEAL_SEND_BACKLOG_CHANGE and SIO_IDEAL_SEND_BACKLOG_QUERY IOCTLs directly.
The inline wrapper function for the SIO_IDEAL_SEND_BACKLOG_CHANGE IOCTL is the idealsendbacklognotify function.
The inline wrapper function for the SIO_IDEAL_SEND_BACKLOG_QUERY IOCTL is the idealsendbacklogquery function.