What is the ioctlsocket () function used? What is the return value? How many parameters are there? What are its parameters used?

Source: Internet
Author: User

1. 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, while
It has nothing to do with specific protocols or communication subsystems. The following commands are supported:
Fionbio: Allows or disables the non-blocking mode of interface S. Argp points to an unsigned long integer. For example
Non-blocking mode is not zero, and non-blocking mode is zero. When you create a set of interfaces
In the 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
For the wsaasynselect () operation, any attempt to use ioctlsocket () to reset the interface set to blocking mode
The image fails with wsaeinval. To reset the set of interfaces to blocking mode, the application must first
Use wsaasynselect () to 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, whose
Contains the return value of ioctlsocket. If S is of the socket_stream type, fionread returns
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 first large datagram value queued on the set interface.
Small.
Siocatmark: whether all out-of-band data has been read. This command only applies
Sock_stream interface, which has been set to receive out-of-band data online
(So_oobinline ). 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 data before the mark.
The application can use the siocatmark operation to determine whether there is any data left. If you are in an "urgent" (out-of-band)
If there is regular data before the data, the data is received in order (note that the Recv () and recvfrom () operations are not performed in
Obfuscation of common and out-of-band data in one call ). Argp points to a bool type, ioctlsocket ()
The returned values are saved.

Compatibility:
This function is a subset of the interface function IOCTL () set by Berkeley. Which is not equivalent to fioasync
Command. siocatmark is the only command supported by the set interface layer.

Return Value:
After the call succeeds, ioctlsocket () returns 0. Otherwise, the socket_error is returned. The application
You can use wsagetlasterror () to obtain the error code.


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 is not applicable to the CMD command, or
This 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 ().

 

 

Ioctlsocket
The Windows Sockets ioctlsocket function controls the I/O mode of a socket.

Int ioctlsocket (
Socket s,
Long cmd,
U_long far * argp
);
Parameters
S
[In] descriptor identifying a socket.
CMD
[In] command to perform on the socket S.
Argp
[In, out] pointer to a parameter for cmd.
Return values
Upon successful completion, the ioctlsocket returns zero. Otherwise, a value of socket_error is returned, and a specific error code can be retrieved by calling wsagetlasterror.

Error code meaning
Wsanotinitialised a successful wsastartup call must occur before using this function.
Wsaenetdown the network subsystem has failed.
Wsaeinprogress a blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
Wsaenotsock the descriptor S is not a socket.
Wsaefault the argp parameter is not a valid part of the user address space.

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.