![]() |
Click here to advertise with us
|
|
|||||||
| Net / Sockets Components for network and related use |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hey, I was wondering how I could actually make a WORKING chat system in visual basic 2008. I've watched tutorials on YouTube, and all of them fail and I get a weird error. I wan't one were you simply put in your buddie's IP and they put in yours and you can talk. A attachment or download link or project sample would be nice
...or codeThanks! |
|
||||
|
Learn about TcpClient and TcpListener. To connect something need to be listening at the other end, a server, that is the job of the TcpListener. To start one create an instance where you specify which ip and port to listen from and call the Start method, keep it in a class variable. This is then needed at minimum at server:
Code:
Private server As TcpListener Code:
server = New TcpListener(ip, port) server.Start() Code:
Dim localIP As Net.IPAddress = Net.Dns.GetHostAddresses("")(0)
Code:
If server.Pending Then
client = server.AcceptTcpClient
Code:
Private client As TcpClient Code:
Private client As TcpClient Code:
client = New TcpClient(ip, port) Code:
Private reader As IO.StreamReader Private writer As IO.StreamWriter Code:
reader = New IO.StreamReader(client.GetStream) writer = New IO.StreamWriter(client.GetStream) writer.AutoFlush = True Code:
writer.WriteLine("message")
Code:
If client.GetStream.DataAvailable Then
Dim msg As String = reader.ReadLine
Finally I will mention cleanups, the server listener is closed with a call to Stop method: Code:
server.Stop() Code:
client.GetStream.Close() Code:
reader.Dispose() writer.Dispose() Code:
client.Close() You will also need to use Try-Catch with several of these calls, as they may and will throw exceptions. Reading the documentation and trying out things will help you understand this.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|