Home |
Function ioctlsocket |
Function ioctlsocketControl socket mode. int ioctlsocket(SOCKET socket, long cmd, DWORD * argp); ParameterssocketSocket number returned by socket or accept. cmdCommand to be performed (FIONBIO, FIONREAD, or FIONWRITE, see below). argpSpecifies whether to turn option on or off for FIONBIO. Returns number of bytes for FIONREAD and FIONWRITE. return valueReturns 0 if successful, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Section Error Codes further describes each error. Possible values for this function are:
The cmd parameter specifies the action to be performed. The command FIONBIO enables or disables non-blocking mode. If the value pointed to by argp is nonzero, it sets the socket's mode to non-blocking, otherwise to blocking mode, which is the default. The command FIONREAD returns the number of bytes available to read. For TCP, the total number of bytes in the input window is returned. For UDP, the total number of bytes in the first UDP packet queued on the socket is returned. The number of bytes available is stored in *argp. The command FIONWRITE returns the number of bytes available to write. For TCP, the number of available bytes in the output window is the size of the output window minus the number of bytes queued. This specifies the number of bytes which may be passed to the send routine without blocking. For UDP, the total number of bytes which may be sent in one message is returned. The number of bytes available is stored in *argp.
|