C# .NET Web Developer's Guide

Creating a UDP Client Server Chat Application

For users, a chat application seems to be a classic P2P application. You send a message to the chat room, and all users that take part at the chat receive the message. So far, you have learned something about the client/server protocol TCP, about the P2P (unicasting), and also peer-to-group (multicasting) protocol UDP. So for a chat application, the UDP multicasting seems to be the best choice (okay, it is the simplest!). You can develop a UDP multicast peer, send this to your friends, and give them a common IP address to connect. You can send messages to this address and all friends that are connected receive these messages a very simple but effective chat application.

Let s do something a little different to show a technique of other applications like Web servers. The result will be an application that guarantees a reliable delivery of the messages from a chat client to a chat server. The server will be a TCP server. You will see how the server can handle more than one client at the same time on the same port. This is like a Web server that responds to many requests at the same time on the standard HTTP port 80. Then, the server sends the messages via UDP to all connected chat clients.

Figure 5.66 shows the three phases from the client s connect request to client/ server communication:

  • Connect The client connects to the server via TCP.

  • Create thread

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Teleconferencing and Webcast Services
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.