Advanced .NET Framework (Network Programming): Use Sockets

This demonstration shows you how to use Sockets in C#.

Featured Highlights:

This application uses .NET sockets classes TcpListener and TcpCLient and StreamWriter to implement a chat server that allows multiple client connections simultaneously. You will learn three important aspects of sockets communication:

1. Server-to-Client communication. The server application allows you to enter text to broadcast to all attached clients. To run this demonstration you need to run the server and at least on instance of the client.

2. Client-to-Client communication. This shows how to send text from a client application to all other attached clients. To run this demonstration you need to run the server with at least two instances of the client running.

3. Client-to-Server request with Server response. This demonstrates the client sending the server a request for a list of all users that are in the chat. When the client receives the response, it fills a listbox with the values.

Requirements:

 Microsoft Visual Studio.NET Professional or greater.
Windows 2000 or Windows XP

Running the Sample:

Launch the server application by loading the How-To Sockets Server Solution and running it by pressing F5.
Then launch clients by loading the How-To Sockets Client Solution and running it by pressing
F5.

See Also

TCP Listener  Working with Sockets