Mono Class Library: System.Net.Sockets.Socket Overview | Members

System.Net.Sockets.Socket.IOControl Method

Provides low-level access to the socket, the transport protocol, or the communications subsystem. [Edit]

public int IOControl (int ioctl_code, byte[] in_value, byte[] out_value)

Parameters

ioctl_code
Documentation for this section has not yet been entered. [Edit]
in_value
Documentation for this section has not yet been entered. [Edit]
out_value
Documentation for this section has not yet been entered. [Edit]

Returns

A int containing the length of the optionOutValue array after the method returns. [Edit]

Permissions

TypeReason
System.Security.Permissions.SecurityPermission [Edit] Requires permission to access unmanaged code. See System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode.

Exceptions

TypeReason
InvalidOperationException

An attempt was made to change the blocking mode.

Note:

Use the Socket.Blocking property to change the blocking mode.

[Edit]
System.Net.Sockets.SocketException
Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]
System.Security.SecurityExceptionA caller in the call stack does not have the required permissions. [Edit]

Remarks

If an attempt is made to change the blocking mode of the current instance, an exception is thrown. Use the Socket.Blocking property to change the blocking mode.

The control codes and their requirements are implementation defined. Do not use this method if platform independence is a requirement.

Note: Input data is not required for all control codes. Output data is not supplied by all control codes and, if not supplied, the return value is 0.

[Edit]

Example

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.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0