VB.NET-INFORMATIONS.COM



VB.NET Communications Tutorial

VB.NET Chat Server

VB.NET Chat Server

The basic function of the Chat Server here is to listening for the connection request from Clients and when the Server get a message , it Broadcast the message to all Clients currently connected to the Server .

vb.net_chat_server.JPG

The VB.NET Multithreaded Chat Server Program has two sections.

1. Chat Server

2. Chat Client

The Chat Server here is a VB.NET Console based application and is listening to the PORT 8888 for the connection request from clients . When the server gets a connection request , it add the name of the Client into a clientsList ( Here it is a Hashtable ) and create a new thread for communication with Server . When the Server get a message from any client , it select all the Clients from clientsList and send the message to all Clients ( ie we can say Broadcast ) in the clientsList . So each Client can see the message each other and they can communicate through Chat Server.

The client list we implemented here in a HashTable . The clientsList stores the Client Name ( ie the first message from Client ) and an instance of the Client Socket .

When a Chat Client connected to Server , the Server create a new Thread for communication . Here we implement a Class handleClient for handling Client as a separate Thread . The Class handleClient has a function doChat() is handling the communication between the Server side Client Socket and the incoming Client Socket.

When Server get a message from any of the currently connected Chat Client , the Server Broadcast the message to all Clients. Here we implement a function broadcast for sending messages to all Clients .

Create a new VB.NET Console based application and put the following source code into the Project.

VB.NET SourceCode


Download Chat Server Program .

Chat Server Download

Chat Client Download

Refer to Chat Server Program for how to run this program .

VB.NET Communications Related Contents
How to send email from VB.NET
VB.NET Send email using CDOSYS
How to find IP Address of Host
How to read a URL Content
VB.NET Socket Programming
VB.NET Server Socket Program
VB.NET Client Socket Program
VB.NET MultiThreaded Socket Programming
VB.NET MultiThreaded Server Socket Programming
VB.NET MultiThreaded Client Socket Programming
VB.NET Chat Server Program
VB.NET Chat Client

VB.NET Related Tpoics
Microsoft .Net Framework Tutorials
VB.NET Language Basics Tutorials
VB.NET Program Flow Control Tutorials
VB.NET Collections Tutorials
VB.NET String Tutorials
VB.NET Files Tutorials
VB.NET Excel 2007 Tutorials
VB.NET Crystal Reports Tutorials
VB.NET Communications Tutorial
VB.NET ADO.NET Tutorial with source code
ADO.NET Data Providers help and Tutorial
VB.NET ADO.NET Dataset Tutorial
ADO.NET DataAdapter and Dataset
VB.NET ADO.NET DataView Tutorial

Search here for more Vb.Net Source Code :


   Categories

    HOME
    VB.NET

 
 
 
   













  |  Home   |  SiteMap   |  About   |
net-informations.com (C) 2008 All Rights Reserved