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.
TUTORIAL FEATURES
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
Amazon Auto Links: No products found.
Thanks for this tutorial. I’m gonna get around to remastering MSN somewhere soon with this.
I recognize that voice. 😀 Didn’t know you had a new channel.
Why TCPControl is not found by Visual Studio Community ?
thank you Sir it Help me more real time projects
You the man! This is pretty good man!
does it have a database?
How can I display the client IP address on the server side using VB.net
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)
‘ SERVER CONFIG
Public ServerIP As IPAddress = IPAddress.Parse(“192.168.0.1”)
Public ServerPort As Integer = 110992
Public Server As TcpListener
Private CommThread As Thread
Public IsListening As Boolean = True
‘ CLIENTS
Private Client As TcpClient
Private ClientData As StreamReader
Public Sub New()
Server = New TcpListener(ServerIP, ServerPort)
Server.Start()
CommThread = New Thread(New ThreadStart(AddressOf Listening))
CommThread.Start()
End Sub
Private Sub Listening()
‘ CREATE LISTENER LOOP
Do Until IsListening = False
‘ ACCEPT INCOMING CONNECTIONS
If Server.Pending = True Then
Client = Server.AcceptTcpClient
ClientData = New StreamReader(Client.GetStream)
End If
‘ REDUCE CPU USAGE
Thread.Sleep(100)
Loop
End Sub
End Class
aparently TCPControl is not a thing for me, help?
error in the (server.start () ) why ??
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.
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
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
?Can I using this pro by Internet or no
So what if i want this to be public? by that i mean multiple people being able to chat? what do i do?
Can i get project?
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 ?
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??
Thanks it is awesome project +vb toolbox
VB Toolbox great video. Can you demonstrate how to do multi clients please?
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 …
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?
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
How i Can Send Data from server to Client ?
how can i use this on 10 computers
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 🙂
Thank you!
Hmm… When I try and run the server it throws me a SocketException
This happens when it reaches Server.Start()
“System.Net.Sockets.SocketException”
“Additional information: The requested address is not valid in its context”
What if it doesn’t connect? What code should I put so it doesn’t crash?
This works on external ip ?? plz answer me !!??
Great video!
Is there a chance you create a tutorial for hosting for multiple clients with using port forwarding of your router? 🙂
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!
Cool! You are the best!