다음을 통해 공유


UdpClient.Client 속성

정의

기본 네트워크를 Socket가져오거나 설정합니다.

public:
 property System::Net::Sockets::Socket ^ Client { System::Net::Sockets::Socket ^ get(); void set(System::Net::Sockets::Socket ^ value); };
protected:
 property System::Net::Sockets::Socket ^ Client { System::Net::Sockets::Socket ^ get(); void set(System::Net::Sockets::Socket ^ value); };
public System.Net.Sockets.Socket Client { get; set; }
protected System.Net.Sockets.Socket Client { get; set; }
member this.Client : System.Net.Sockets.Socket with get, set
Public Property Client As Socket
Protected Property Client As Socket

속성 값

기본 네트워크 Socket.

예제

다음 예제에서는 속성의 사용을 보여 줍니다 Client . 이 예제에서는 기본에 대해 브로드캐스팅을 사용하도록 설정됩니다 Socket.

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 demonstrates the use of three protected methods belonging to the UdpClient class.
Public Class MyUdpClientDerivedClass
   Inherits UdpClient
   
   Public Sub New()
   End Sub
   
   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
End Class

설명

UdpClientSocket 네트워크를 통해 데이터를 보내고 받는 데 사용되는 를 만듭니다. 파생되는 UdpClient 클래스는 이 속성을 사용하여 이 Socket속성을 얻거나 설정할 수 있습니다. 제공하는 것 이상으로 액세스해야 하는 경우 반환 Client 되는 UdpClient 기본 Socket 을 사용합니다. 기본 Socket 을 기존으로 설정하는 데 사용할 Client 수도 있습니다Socket. 이 기능은 기존 Socket사용의 UdpClient 단순성을 활용하려는 경우에 유용합니다.

적용 대상

추가 정보