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 クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



UdpClient.Client プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS