Share via


IPv6 Sockets Sample

This sample demonstrates how to use sockets when IPv6 is enabled. The sample consists of client and a server. The client can send a message to the server and the server responds. The client uses the AddressFamily property on the IPAddress objects returned by the Dns class, and to create the socket. The client loops through all of the IP addresses returned until it is able to connect to one successfully, or it has attempted to connect to all the IP addresses it has retrieve using the DNS class.

To build the sample using the command prompt

  1. Open a command prompt and navigate to one of the language-specific subdirectories under the IPv6Sockets directory. For information about required settings and the SDK command prompt, see How to: Set Sample Settings.

  2. Type msbuild IPv6Sockets<lang>.sln at the command line, where <lang> is either CS or VB.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to one of the language-specific subdirectories under the IPv6Sockets directory.

  2. Double-click the icon for the IPv6Sockets<lang>.sln to open the file in Visual Studio, where <lang> is either CS or VB.

  3. On the Build menu, click Build Solution.

    The application will be built in the default \bin\Debug directory.

To run the sample

  1. Navigate to the directory containing the new executable for IPv6Server, using the command prompt.

  2. Type IPv6Server.exe at the command line.

  3. Navigate to the directory containing the new executable for IPv6Client, using the command prompt.

  4. Type IPv6Client.exe at the command line.

    NoteNote

    The sample builds a console application. You must launch and run it from a command prompt to view its output.

Requirements

The server is called IPv6Server, and the client is IPv6Client. You build the solution using the solution file IPv6Sockets<lang>.sln, where <lang> is either CS or VB. To start the server, run IPv6Server.exe. To run the client, run IPv6Client <server_name>, specifying the DNS name of the server. 

See Also

Reference

System.Net.Sockets