Socket::AddressFamily Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the address family of the Socket.

Namespace:   System.Net.Sockets
Assembly:  System (in System.dll)

property AddressFamily AddressFamily {
	AddressFamily get();

Property Value

Type: System.Net.Sockets::AddressFamily

One of the AddressFamily values.

The AddressFamily specifies the addressing scheme that an instance of the Socket class can use. This property is read-only and is set when the Socket is created.

The following code example displays the AddressFamily, SocketType, and ProtocolType to the console.

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() );

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Return to top