I want to develop a chat application with a server/client model, opening TCP or UDP sockets in VISUAL BASIC 2008. Is there a working example I can download, or some code to help me with this project?
Thanks in advance.
Edit: Thanks for the answer, really really appreciate it. But im stack somewhere, because my application will work only locally, but not throughout the Internet.
My code on the server part is the following:
enter code here readData = "Conected to Chat Server ..." LabelConnection.Text = "Connected" PictureBox1.Image = My.Resources.Globe_Connected_Icon_39x33 PictureBox1.BackColor = Color.Transparent msg() clientSocket.Connect("127.0.0.1", 8888) enter code here
Now, instead of 127.0.0.1 I should put some variable or something that keeps the IP address of the targe开发者_如何学运维t machine? How would I do that? Can anyone help?
Essentially, you'll need to build a chat server application and a client program that connects to the server and initiates the data exchange. To really make this work right, you're also going to have to learn a little bit about threading so that your client/listener runs asynchronously.
Here's a list of sample projects to take a look at:
Wintalk (a Microsoft-provided sample to introduce WinForms, sockets, and the .NET Framework)
Creating a Multi-User TCP Chat Application
A TCP/IP Chat Program
Simple Chat Application Using .NET Sockets
A Chat Application Using Asynchronous TCP Sockets
TCP/IP Chat Application Using C#
VB.NET Sockets Client Class
Anything you might find that is written in C# (like a few of the above samples) should be relatively straightforward to convert to VB.NET. If you need some additional guidance, try some of the available online conversion tools, such as the one provided by DeveloperFusion.
Finally, the MSDN documentation for the System.Net.Sockets
namespace (which you'll be using extensively) is an excellent resource as you start digging through the sample projects and find yourself with some nagging, unanswered questions.
精彩评论