VB.NET Chat Client

The Chat Client is a sophisticated Windows-based application designed to facilitate seamless communication through its myriad of features. Its primary objective revolves around the transmission of messages to the Chat Server, making it an indispensable tool for efficient and reliable messaging.

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

1. Chat Server

2. Chat Client

Chat Client

To establish a connection with the Chat Server, the Chat Client utilizes the designated PORT 8888 while targeting the IP address "" The selection of this IP address stems from the fact that both the Chat Server and Chat Client reside on the same machine, ensuring a swift and secure connection.

Upon launching the Chat Client program, the user is prompted to enter a unique User Name, serving as an identifier within the Server. This personal touch enhances the user experience, allowing for personalized interactions within the Chat Server environment.


To streamline message reception, the Chat Client program initiates a connection with the Chat Server and spawns a dedicated Thread for message retrieval. Within this thread, we implement an infinite loop, cleverly designed in the function getMessage(), which consistently listens for incoming messages from other clients. By encapsulating this functionality within a separate Thread, the Chat Client ensures uninterrupted communication without hampering the overall performance of the application.

Create a new VB.NET Windows based project and put the source code in it.

Full Source VB.NET
Imports System.Net.Sockets Imports System.Text Public Class Form1 Dim clientSocket As New System.Net.Sockets.TcpClient() Dim serverStream As NetworkStream Dim readData As String Dim infiniteCounter As Integer Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim outStream As Byte() = _ System.Text.Encoding.ASCII.GetBytes(TextBox2.Text + "$") serverStream.Write(outStream, 0, outStream.Length) serverStream.Flush() End Sub Private Sub msg() If Me.InvokeRequired Then Me.Invoke(New MethodInvoker(AddressOf msg)) Else TextBox1.Text = TextBox1.Text + _ Environment.NewLine + " >> " + readData End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click readData = "Conected to Chat Server ..." msg() clientSocket.Connect("", 8888) 'Label1.Text = "Client Socket Program - Server Connected ..." serverStream = clientSocket.GetStream() Dim outStream As Byte() = _ System.Text.Encoding.ASCII.GetBytes(TextBox3.Text + "$") serverStream.Write(outStream, 0, outStream.Length) serverStream.Flush() Dim ctThread As Threading.Thread = _ New Threading.Thread(AddressOf getMessage) ctThread.Start() End Sub Private Sub getMessage() For infiniteCounter = 1 To 2 infiniteCounter = 1 serverStream = clientSocket.GetStream() Dim buffSize As Integer Dim inStream(10024) As Byte buffSize = clientSocket.ReceiveBufferSize serverStream.Read(inStream, 0, buffSize) Dim returndata As String = _ System.Text.Encoding.ASCII.GetString(inStream) readData = "" + returndata msg() Next End Sub End Class
Download Chat Server Program

Chat Server Download

Chat Client Download

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


The Chat Client embodies the essence of user-centric design, empowering individuals to connect effortlessly with the Chat Server. Through its intelligent utilization of PORT 8888 and the IP address "," seamless communication within the same machine is achieved. The inclusion of a personalized User Name feature enhances the user experience, while the implementation of a dedicated message reception Thread ensures uninterrupted and efficient message retrieval.