Ioctlsocket ()

Source: Internet
Author: User
Ioctlsocket ()

Brief description:
Control Set interface mode.
# Include <Winsock. h>
Int Pascal far ioctlsocket (socket s, long cmd, u_long far * argp );
S: The description of an identity set interface.
CMD: Operation Command for set interface S.
Argp: pointer to the parameter included in the CMD command.
Note:
This function can be used for any interface in any status. It is used to obtain operation parameters related to the set interface, but is not related to the specific Protocol or communication subsystem. The following commands are supported:
Fionbio: Allows or disables the non-blocking mode of interface S. Argp points to an unsigned long integer. If the non-blocking mode is allowed, the value is non-zero. If the non-blocking mode is disabled, the value is zero. When an interface is created, it is in blocking mode (that is, the non-blocking mode is disabled ). This is consistent with the BSD interface. The wsaasynselect () function automatically sets the set interface to non-blocking mode. If you have performed the wsaasynselect () operation on a set of interfaces, any attempt to reset the set of interfaces to the blocking mode by using ioctlsocket () will fail with wsaeinval. In order to re-set the set interface to blocking mode, the application must first use the wsaasynselect () call (the ievent parameter is set to 0) to disable wsaasynselect ().
Fionread: determines the amount of data automatically read by the set of interface S. Argp points to an unsigned long integer with the return value of ioctlsocket. If S is of the socket_stream type, fionread returns all data volumes received in a Recv. This is usually the same as the total amount of data queued in the socket. If S is of the sock_dgram type, fionread returns the size of the first datagram queued on the set interface.
Siocatmark: whether all out-of-band data has been read. This command is only applicable to _stream APIs, and has been set to receive out-of-band data (so_oobinline) online ). If no out-of-band data is waiting for reading, this operation returns true. Otherwise, false or false is returned. The next Recv () or recvfrom () operation retrieves some or all of the data before the mark. The application can use the siocatmark operation to determine whether there is any data left. If regular data exists before "urgent" (out-of-band) data, it is received in order (note that Recv () and recvfrom () the operation will not confuse general data with out-of-band data in one call ). Argp points to a bool type, where ioctlsocket () stores the returned value.
Compatibility:
This function is a subset of the interface function IOCTL () set by Berkeley. There are no commands equivalent to fioasync, and siocatmark is the only command supported at the set interface level.
Return Value:
After the call succeeds, ioctlsocket () returns 0. Otherwise, the socket_error is returned. The application can obtain the error code through wsagetlasterror.
Error code:
Wsanotinitialised: before using this API, you must successfully call wsastartup ().
Wsaenetdown: A Windows interface is used to detect the failure of the network subsystem.
Wsaeinval: The cmd command is invalid, or the parameter specified by argp does not apply to the CMD command, or the command
This type of interface is not applicable.
Wsaeinss SS: A blocked Windows interface call is running.
Wsaenotsock: The description is not a set of interfaces.
See:
Socket (), setsockopt (), getsockopt (), wsaasyncselect ().

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.