Socket.AddressFamily 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 Socket 的地址族。
public:
property System::Net::Sockets::AddressFamily AddressFamily { System::Net::Sockets::AddressFamily get(); };
public System.Net.Sockets.AddressFamily AddressFamily { get; }
member this.AddressFamily : System.Net.Sockets.AddressFamily
Public ReadOnly Property AddressFamily As AddressFamily
属性值
AddressFamily 值之一。
示例
下面的代码示例显示 AddressFamily控制台 SocketType和 ProtocolType 控制台。
Socket^ s = gcnew Socket( lep->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp );
//Uses the AddressFamily, SocketType, and ProtocolType properties.
Console::Write( "I just set the following properties of socket: \n" );
Console::Write( "Address Family = {0}", s->AddressFamily.ToString() );
Console::Write( "\nSocketType = {0}", s->SocketType.ToString() );
Console::WriteLine( "\nProtocolType = {0}", s->ProtocolType.ToString() );
Socket s = new Socket (lep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
//Using the AddressFamily, SocketType, and ProtocolType properties.
Console.WriteLine ("I just set the following properties of socket: " + "Address Family = " + s.AddressFamily.ToString () + "\nSocketType = " + s.SocketType.ToString () + "\nProtocolType = " + s.ProtocolType.ToString ());
Dim s As New Socket(lep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
'Using the AddressFamily, SocketType, and ProtocolType properties.
Console.WriteLine(("I just set the following properties of socket: " + "Address Family = " + s.AddressFamily.ToString() + ControlChars.Cr + "SocketType = " + s.SocketType.ToString() + ControlChars.Cr + "ProtocolType = " + s.ProtocolType.ToString()))
注解
指定 AddressFamily 类实例可以使用的 Socket 寻址方案。 此属性是只读的, Socket 在创建时设置。