Socket の低レベル操作モードを設定します。
Public Function IOControl( _
ByVal ioControlCode As Integer, _ ByVal optionInValue() As Byte, _ ByVal optionOutValue() As Byte _) As Integer
[C#]
public int IOControl(intioControlCode,byte[] optionInValue,byte[] optionOutValue);
[C++]
public: int IOControl(intioControlCode,unsigned charoptionInValue __gc[],unsigned charoptionOutValue __gc[]);
[JScript]
public function IOControl(
ioControlCode : int,optionInValue : Byte[],optionOutValue : Byte[]) : int;
パラメータ
- ioControlCode
実行する演算の制御コード。 - optionInValue
演算に必要な入力データを格納する Byte 型の配列。 - optionOutValue
演算によって返された出力データを格納する Byte 型の配列。
戻り値
optionOutValue パラメータのバイト数。
例外
例外の種類 | 条件 |
---|---|
SocketException | ソケットへのアクセスを試みているときにエラーが発生しました。詳細については「解説」を参照してください。 |
ObjectDisposedException | Socket は閉じられています。 |
InvalidOperationException | Blocking プロパティを使用せずに、ブロッキング モードを変更しようとしました。 |
SecurityException | コール スタック内の呼び出し元が、要求されたアクセス許可を保持していません。 |
解説
IOControl メソッドは、 Socket クラスの現在のインスタンスの基になるオペレーティング システム Socket への低レベル アクセスを提供します。 IOControl の詳細については、MSDN の WSAIoctl のドキュメントを参照してください。
メモ SocketException が発生した場合は、 SocketException.ErrorCode を使用して具体的なエラー コードを取得してください。このコードを取得したら、Windows Socket Version 2 API エラー コードのマニュアルから、エラーの詳細情報を確認できます。これは MSDN から入手できます。
使用例
[C#, C++] 次に示すのは、FIONREAD を使用した場合と Available プロパティを使用した場合の結果を比較するコード例です。
// FIONREAD is also available as the "Available" property.
public const int FIONREAD = 0x4004667F;
static void DisplayPendingByteCount(Socket s)
{
byte[] outValue = BitConverter.GetBytes(0);
// Check how many bytes have been received.
s.IOControl(FIONREAD, null, outValue);
uint bytesAvailable = BitConverter.ToUInt32(outValue, 0);
Console.WriteLine("server has {0} bytes pending. Available property says {1}.",
bytesAvailable, s.Available);
return;
}
[C++]
// FIONREAD is also available as the "Available" property.
const int FIONREAD = 0x4004667F;
void DisplayPendingByteCount(Socket* s)
{
Byte outValue[] = BitConverter::GetBytes(0);
// Check how many bytes have been received.
s->IOControl(FIONREAD, 0, outValue);
UInt32 bytesAvailable = BitConverter::ToUInt32(outValue, 0);
Console::WriteLine(S"server has {0} bytes pending. Available property says {1}.", __box(bytesAvailable), __box(s->Available));
return;
}
[Visual Basic, JScript] Visual Basic および JScript のサンプルはありません。C# および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard