SocketAddress クラス
アセンブリ: System (system.dll 内)
構文
解説元になるバッファの最初の 2 バイトは、AddressFamily 列挙値用に予約されています。シリアル化した IPEndPoint の格納に SocketAddress を使用した場合、3 番目と 4 番目のバイトは、ポート番号情報の格納用に使用されます。後続のバイトは、IP アドレスを格納するために使用されます。バイト バッファは、0 から始まるインデックス番号を使用するため、このインデックス位置を参照して、基になるバイト バッファ内のすべての情報にアクセスできます。Family プロパティおよび Size プロパティを使用して、AddressFamily 値とバッファ サイズをそれぞれ取得することもできます。任意の情報を文字列として表示するには、ToString メソッドを使用します。
使用例SocketAddress を使用して、EndPoint クラスのインスタンスをシリアル化する方法の例を次に示します。シリアル化が完了すると、SocketAddress の基になるバイト バッファには、すべての IPEndPoint ステータス情報が格納されます。
'Creates an IpEndPoint. Dim ipAddress As IPAddress = Dns.Resolve("www.contoso.com").AddressList(0) Dim ipLocalEndPoint As New IPEndPoint(ipAddress, 11000) 'Serializes the IPEndPoint. Dim socketAddress As SocketAddress = ipLocalEndPoint.Serialize() 'Verifies that ipLocalEndPoint is now serialized by printing its contents. Console.WriteLine(("Contents of socketAddress are: " + socketAddress.ToString())) 'Checks the Family property. Console.WriteLine(("The address family of socketAddress is: " + socketAddress.Family.ToString())) 'Checks the underlying buffer size. Console.WriteLine(("The size of the underlying buffer is: " + socketAddress.Size.ToString())) End Sub 'MySerializeIPEndPointClassMethod
//Creates an IpEndPoint. IPAddress ipAddress = Dns.Resolve("www.contoso.com").AddressList[0]; IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000); //Serializes the IPEndPoint. SocketAddress socketAddress = ipLocalEndPoint.Serialize(); //Verifies that ipLocalEndPoint is now serialized by printing its contents. Console.WriteLine("Contents of the socketAddress are: " + socketAddress.ToString()); //Checks the Family property. Console.WriteLine("The address family of the socketAddress is: " + socketAddress.Family.ToString()); //Checks the underlying buffer size. Console.WriteLine("The size of the underlying buffer is: " + socketAddress.Size.ToString());
//Creates an IpEndPoint. IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); //Serializes the IPEndPoint. SocketAddress^ socketAddress = ipLocalEndPoint->Serialize(); //Verifies that ipLocalEndPoint is now serialized by printing its contents. Console::WriteLine( "Contents of the socketAddress are: {0}", socketAddress ); //Checks the Family property. Console::WriteLine( "The address family of the socketAddress is: {0}", socketAddress->Family ); //Checks the underlying buffer size. Console::WriteLine( "The size of the underlying buffer is: {0}", socketAddress->Size );
//Creates an IpEndPoint. IPAddress ipAddress = (IPAddress)Dns.Resolve( "www.contoso.com").get_AddressList().get_Item(0); IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000); //Serializes the IPEndPoint. SocketAddress socketAddress = ipLocalEndPoint.Serialize(); //Verifies that ipLocalEndPoint is now serialized by printing its //contents. Console.WriteLine(("Contents of the socketAddress are: " + socketAddress.ToString())); //Checks the Family property. Console.WriteLine(("The address family of the socketAddress is: " + socketAddress.get_Family())); //Checks the underlying buffer size. Console.WriteLine(("The size of the underlying buffer is: " + socketAddress.get_Size()));
継承階層System.Net.SocketAddress
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照SocketAddress コンストラクタ (AddressFamily)
アセンブリ: System (system.dll 内)
構文
解説
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照SocketAddress コンストラクタ
オーバーロードの一覧| 名前 | 説明 |
|---|---|
| SocketAddress (AddressFamily) | 指定したアドレス ファミリの SocketAddress クラスの新しいインスタンスを作成します。 .NET Compact Framework によってサポートされています。 |
| SocketAddress (AddressFamily, Int32) | 指定したアドレス ファミリとバッファ サイズを使用して、SocketAddress クラスの新しいインスタンスを作成します。 .NET Compact Framework によってサポートされています。 |
参照SocketAddress コンストラクタ (AddressFamily, Int32)
アセンブリ: System (system.dll 内)
構文
例外
解説
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照SocketAddress プロパティ
SocketAddress メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 オーバーライドされます。 |
| GetHashCode | オーバーライドされます。 特定の型のハッシュ関数として機能します。ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| ToString | オーバーライドされます。 ソケット アドレスに関する情報を返します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照SocketAddress メンバ
EndPoint 派生クラスからシリアル化された情報を格納します。
SocketAddress データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 オーバーライドされます。 |
| GetHashCode | オーバーライドされます。 特定の型のハッシュ関数として機能します。ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| ToString | オーバーライドされます。 ソケット アドレスに関する情報を返します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照- SocketAddressのページへのリンク