VB.NET Tutorial – Client / Server Network Programming – Simple Chat Application

In this Visual Basic .NET programming tutorial I will be teaching you how to create a simple client / server chat program and relay messages across a network using a TCPClient and TCPListener.

Windows Sockets – TCPClient, TCPListener
Network Programming – Server & Client, Open ports and listen
Custom Events – Detect and relay message data to form controls
Threading – Create and manage a background worker thread
Streams – StreamReader & StreamWriter
Windows Forms – TextBox, Button

Source Code: https://www.dropbox.com/s/3nry22aqis1htq5/TCP%20TUTORIAL%20Projects.zip?dl=0

TIP JAR: http://www.aardaerimus.com/tipjar.asp


xsychoreese says:

Thanks for this tutorial. I’m gonna get around to remastering MSN somewhere soon with this.

kevnar says:

I recognize that voice. 😀 Didn’t know you had a new channel.

Sixestla says:

Why TCPControl is not found by Visual Studio Community ?

sarinkumar patle says:

thank you Sir it Help me more real time projects

Kevin Shaw says:

You the man! This is pretty good man!

zeo sui says:

does it have a database?

May Yishun says:

How can I display the client IP address on the server side using VB.net

Furby Mine says:

I got an error at the part when we were making the TCPcontrol class the error was on line 24 and it was the text : Server.Start in the public sub new , the error was : System.ArgumentOutOfRangeException: ‘Specified argument was out of the range of valid values.’
: Anyone know the fix to it ?

Here is my code :

Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading

Public Class TCPcontrol
Public Event MessageReceived(sender As TCPcontrol, Data As String)


Public ServerIP As IPAddress = IPAddress.Parse(“”)
Public ServerPort As Integer = 110992
Public Server As TcpListener

Private CommThread As Thread
Public IsListening As Boolean = True

Private Client As TcpClient
Private ClientData As StreamReader

Public Sub New()
Server = New TcpListener(ServerIP, ServerPort)

CommThread = New Thread(New ThreadStart(AddressOf Listening))
End Sub

Private Sub Listening()
Do Until IsListening = False
If Server.Pending = True Then
Client = Server.AcceptTcpClient
ClientData = New StreamReader(Client.GetStream)
End If

End Sub
End Class

Legojack100 Plays says:

aparently TCPControl is not a thing for me, help?

Huda Kurniawan says:

error in the (server.start () ) why ??

TheManeOfLife says:

I want to make a game, that is multiplayer in VB.NET (I really do). I want to do VB.NET because my friend only knows this particular language. I want the game to be a mini RPG game. Like a 1,2,3,4v1,2,3,4. Can someone please help me, I really want to help my friend. With this game he is making, because I also want to make the game as much as he wants to make the game too.

Kip Russel says:

can i start sending files thru server’s PC using this codes? I’m working on my capstone and I’m new to network programming

aldwyn joaquin says:

hi i made the same program as yours thanks alot the problem is when i copy the exe of client on my desktop then my server is laptop we are both connected on the same internet.. but when i click connect it says this machine does not allow “my ip” can u pm me your mail so i can send picture?!?!tnx alot sir

ايمن ميمون says:

?Can I using this pro by Internet or no

StydianX GameTV says:

So what if i want this to be public? by that i mean multiple people being able to chat? what do i do?

ťumikk says:

Can i get project?

Jhealyn Caerlang says:

Sir what if you have form full of text box and copy all inputs in that form from client then send all the input entry into the server
How to do it? is it the same ?

Grandus11 says:

I have a program in VB6 that allows me to use the same ip address and port and it uses sockets to allow more than one computer to connect to the ip address and port is there a way to do this in the server section of this program??

Zeyad Ahmed says:

Thanks it is awesome project +vb toolbox

James Kulwicki says:

VB Toolbox great video. Can you demonstrate how to do multi clients please?

Agus Sumarya says:

fantastic tutorial, 100% work! Thank you very much! These channels help me so much!
but how to make a chat application with one form as on the client side .. ??
please share …

amrita jannu says:

Really nice tutorial helped me a lot. But i am just curious to know how do i respond from server to client? Could you help me with that?

Reggie Fudot says:

Guys Please help me When ever i click send from my laptop into another laptop all i get is an error.
If laptop 1 says = “me: hello” then
my 2nd laptop will crash and say No Sources Available and says No Such host is known
But my 1st and 2nd laptop is connected but every time i send something my 2nd laptop is crash
Please help me guys thank you very much

erikpro007 says:

How i Can Send Data from server to Client ?


how can i use this on 10 computers

Yash Somani says:

Hey VB Toolbox, what a wonderful tutorial. Learnt everything soo perfectly.
My Question is can i assign names to the clients and in the server form in the txtChat, can i show something like :
ClientName1 : TheMessage
Can i? Please tell me how. Reply asap. Thanks again :)

Albert Touchinsky says:

Thank you!

OneBigPlayLister says:

Hmm… When I try and run the server it throws me a SocketException

This happens when it reaches Server.Start()

“Additional information: The requested address is not valid in its context”

Neutron Star says:

What if it doesn’t connect? What code should I put so it doesn’t crash?

tnaket life says:

This works on external ip ?? plz answer me !!??

Bo Ikz says:

Great video!
Is there a chance you create a tutorial for hosting for multiple clients with using port forwarding of your router? :)

joy angelou Castillo says:

Hello sir, I am having a problem with the server txtchat, it doesn’t display the text that I have sent. I just did what’s on this tutorial. :-) Can you help me ? thank you!

Bence Balog says:

Cool! You are the best!

Write a comment


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours