UdpClient.Client プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > UdpClient.Client プロパティの意味・解説 

UdpClient.Client プロパティ

基になるネットワーク Socket を取得または設定します。

名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文構文

解説解説

UdpClient は、ネットワーク上でデータを送受信するときに使用する Socket を作成します。UdpClient の派生クラスはこのプロパティを使用してこの Socket を取得または設定します。UdpClient が提供する以上のアクセスが必要な場合は、Client が返した基になる Socket を使用します。Client を使用して、基になる Socket を既存の Socket に設定することもできます。この方法は、既存の Socket を使用して UdpClient の単純性を利用する場合に役に立つことがあります。

使用例使用例

Client プロパティを使用する例を次に示します。この例では、基になる Socket に対してブロードキャストを有効にしています。

' This derived class demonstrates the use of three protected methods
 belonging to the UdpClient class.
Public Class MyUdpClientDerivedClass
   Inherits UdpClient
   
   Public Sub New()
   End Sub 'New
   
   Public Sub UsingProtectedMethods()
      
      'Uses the protected Active property belonging to the UdpClient
 base class to determine if a connection is established.
      If Me.Active Then
         ' Calls the protected Client property belonging to the UdpClient
 base class.
         Dim s As Socket = Me.Client
              'Uses the Socket returned by Client to set an option that
 is not available using UdpClient.
         s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast,
 1)
      End If
   End Sub 'UsingProtectedMethods
 
End Class 'MyUdpClientDerivedClass
 

public static void Main(string[]
 args)
{
    if (args.Length < 1)
    {
        Console.WriteLine("you must specify a port number!");
        return;
    }

    UdpClient uClient = new UdpClient(Convert.ToInt32(args[0]));
    Socket uSocket = uClient.Client;

    // use the underlying socket to enable broadcast.
    uSocket.SetSocketOption(SocketOptionLevel.Socket, 
                  SocketOptionName.Broadcast, 1);
}
// This derived class demonstrate the use of three protected methods
 belonging to the UdpClient class.
public ref class MyUdpClientDerivedClass: public
 UdpClient
{
public:
   MyUdpClientDerivedClass()
      : UdpClient()
   {}

   void UsingProtectedMethods()
   {
      //Uses the protected Active property belonging to the UdpClient
 base class to determine if a connection is established.
      if ( this->Active )
      {
         //Calls the protected Client property belonging to the UdpClient
 base class.
         Socket^ s = this->Client;

         //Uses the Socket returned by Client to set an option that
 is not available using UdpClient.
         s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Broadcast,
 1 );
      }
   }
};
// This derived class demonstrate the use of three protected methods
// belonging to the UdpClient class.
public class MyUdpClientDerivedClass extends
 UdpClient
{
    public MyUdpClientDerivedClass()
    {
        super();
    } //MyUdpClientDerivedClass

    public void UsingProtectedMethods()
    {
        // Uses the protected Active property belonging to the UdpClient
 base
        // class to determine if a connection is established.
        if (this.get_Active()) {
            //Calls the protected Client property belonging 
            //to the UdpClient base class.
            Socket s = this.get_Client();
            //Uses the Socket returned by Client to set an 
            //option that is not available using UdpClient.
            s.SetSocketOption(SocketOptionLevel.Socket,
                SocketOptionName.Broadcast, 1);
        }
    } //UsingProtectedMethods
} //MyUdpClientDerivedClass
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UdpClient クラス
UdpClient メンバ
System.Net.Sockets 名前空間
Socket クラス



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

UdpClient.Client プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



UdpClient.Client プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS