UdpClient.Client プロパティ
アセンブリ: System (system.dll 内)

基になるネットワーク Socket。

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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からUdpClient.Client プロパティを検索する場合は、下記のリンクをクリックしてください。

- UdpClient.Client プロパティのページへのリンク