使用 VB 2008 的在线聊天应用程序,使用 TCP 或 UDP 套接字

发布于 2024-10-02 07:09:33 字数 508 浏览 1 评论 0原文

我想开发一个具有服务器/客户端模型的聊天应用程序,在 VISUAL BASIC 2008 中打开 TCP 或 UDP 套接字。是否有一个可以下载的工作示例,或者一些代码来帮助我完成这个项目?

提前致谢。


编辑:谢谢您的回答,真的非常感谢。但我堆栈在某个地方,因为我的应用程序只能在本地运行,而不能在整个互联网上运行。

我在服务器部分的代码如下:

在此处输入代码 readData = "已连接到聊天服务器 ..." LabelConnection.Text = "已连接" PictureBox1.Image = My.Resources.Globe_Connected_Icon_39x33 PictureBox1.BackColor = Color.Transparent msg() clientSocket.Connect("127.0.0.1", 8888) 在此处输入代码

现在,我应该放置一些变量或其他内容来保留目标计算机的 IP 地址,而不是 127.0.0.1?我该怎么做呢?有人可以帮忙吗?

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 target machine? How would I do that? Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漫雪独思 2024-10-09 07:09:33

本质上,您需要构建一个聊天服务器应用程序和一个连接到服务器并启动数据交换的客户端程序。为了真正使这项工作正常进行,您还必须学习一些有关线程的知识,以便您的客户端/侦听器异步运行。

以下是可供查看的示例项目列表:

您可能会发现用 C# 编写的任何内容(如上面的一些示例)都应该相对简单地转换为 VB.NET。如果您需要一些额外的指导,请尝试一些可用的在线转换工具,例如 DeveloperFusion

最后,MSDN 文档System.Net.Sockets 命名空间(您将广泛使用)的 a> 是一个极好的资源。

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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文