Sets low-level operating modes for the System.Net.Sockets.Socket using numerical control codes.
- ioctl_code
- Documentation for this section has not yet been entered.
- in_value
- Documentation for this section has not yet been entered.
- out_value
- Documentation for this section has not yet been entered.
The number of bytes in the optionOutValue parameter.
Type Reason InvalidOperationException An attempt was made to change the blocking mode.
Note:Use the Socket.Blocking property to change the blocking mode.
System.Net.Sockets.SocketException Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.ObjectDisposedException The current instance has been disposed. System.Security.SecurityException A caller in the call stack does not have the required permissions.
The Socket.IOControl(int, Byte[], Byte[]) method provides low-level access to the operating system System.Net.Sockets.Socket underlying the current instance of the System.Net.Sockets.Socket class. For more information, see the WSAIoctl documentation in the MSDN library.
If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Type | Reason |
---|---|
System.Security.Permissions.SecurityPermission | Requires permission to access unmanaged code. See System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode. |
The following example gets the number of bytes of available data to be read and writes the result to the console on a Windows system. The remote endpoint (remoteEndpoint) to connect to might need to be changed to a value that is valid on the current system.
C# Example
using System; using System.Net; using System.Net.Sockets; class App { static void Main() { IPAddress remoteAddress = Dns.Resolve(Dns.GetHostName()).AddressList[0]; IPEndPoint remoteEndpoint = new IPEndPoint(remoteAddress, 80); Socket someSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); someSocket.Connect(remoteEndpoint); int fionRead = 0x4004667F; byte[]inValue = {0x00, 0x00, 0x00, 0x00}; byte[]outValue = {0x00, 0x00, 0x00, 0x00}; someSocket.IOControl(fionRead, inValue, outValue); uint bytesAvail = BitConverter.ToUInt32(outValue, 0); Console.WriteLine( "There are {0} bytes available to be read.", bytesAvail.ToString() ); } }
The output is
There are 0 bytes available to be read.