Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Socket.AddressFamily Property

Gets the address family of the Socket.

[Visual Basic]
Public ReadOnly Property AddressFamily As AddressFamily
[C#]
public AddressFamily AddressFamily {get;}
[C++]
public: __property AddressFamily get_AddressFamily();
[JScript]
public function get AddressFamily() : AddressFamily;

Property Value

One of the AddressFamily values.

Remarks

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.

Example

[Visual Basic, C#, C++] The following example displays the AddressFamily, SocketType, and ProtocolType to the console.

[Visual Basic] 
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()))


[C#] 
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 ());


[C++] 
Socket *s = new 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 = ");
Console::Write(__box(s->AddressFamily)->ToString());
Console::Write("\nSocketType = ");
Console::Write(__box(s->SocketType)->ToString());
Console::Write("\nProtocolType = ");
Console::WriteLine(__box(s->ProtocolType)->ToString());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace | AddressFamily

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft