使用Delphi 2010编写TCP IP消息系统(客户端/服务器)的建议

发布于 2024-10-09 14:55:59 字数 463 浏览 5 评论 0原文

我想在 Delphi 2010 中使用 TCP IP 编写一个消息传递系统。我想听听使用标准 delphi 2010 组件/indy 组件来执行此操作的最佳选择是什么。

我想编写一个服务器,它可以侦听消息并将消息转发到网络上运行客户端的所有计算机。

1.) a.) 客户端可以将消息发送到服务器以转发给所有其他客户端 b.) 客户端侦听来自其他发送者的消息(通过服务器)并显示消息。

2.) a.) 服务器可以向所有客户端发送消息 b.) 服务器将来自客户端的任何消息转发给所有其他客户端,

感谢您的任何建议

注意:我不是在编写即时消息或聊天程序。这只是一个用户可以向其他用户发送警报/消息的系统 - 他们不能互相回复!禁止任何商业、共享软件等链接 - 请!我想听听您将如何编写此类系统以及您将采用什么方法,以及您可能会使用的 TCP IP 消息传递架构。无论是直接的 Winows API、Indy 组件等等。

I would like to write a messaging system using TCP IP in Delphi 2010. I would like to hear what my best options are for using the standard delphi 2010 components/indy components for doing this.

I would like to write a server which does the listening and forwarding of messages to all machines on the network running a client.

1.) a.) clients can send a message to server to be forwarded to all other clients
b.) clients listen for messages from other senders (via server) and displays messages.

2.) a.) Server can send a message to all clients
b.) Server forwards any messages from clients to all other clients

thanks for any suggestions

NOTE: I am not writing a instant messaging or chat program. This is merely a system where users can send alerts/messages to other users - they can not reply to each other! NO commercial, shareware, etc links - please! I would like to hear about how you would go about writing this type of system and what approachs you would take, and possibly the TCP IP messaging architecture you would use. Whether it be straight Winows API, Indy components, etc, etc.

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

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

发布评论

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

评论(6

谁许谁一生繁华 2024-10-16 14:55:59

如果这仅限于 Windows,并且您不想使用第 3 方库,那么您可以跳过 TCP/IP 并转到 邮槽

编辑:如果您想要保证交付,那么命名管道是更好的解决方案。 这个SO问题有一个很少很好使用 Delphi 命名管道示例回答

邮槽是一种单向机制
进程间通信(IPC)。
应用程序可以将消息存储在
邮槽。邮槽的所有者
可以检索存储的消息
那里。这些消息通常是
通过网络发送到
指定计算机或所有计算机
在指定的域中。一个域是一个
工作站和服务器组
共享群组名称

他们不需要 Windows 域,他们通过 LAN 工作。

DelphiPages 有一个很好的在 Delphi 中进行 IPC 的简述,包括邮槽。

——杰罗恩

If this is Windows only, and you don't want to use 3rd party libraries, then you can skip TCP/IP and go for Mailslots.

Edit: if you want guaranteed delivery, than named pipes is a better solution. This SO question has a few nice answers with Delphi named pipe examples.

A mailslot is a mechanism for one-way
interprocess communications (IPC).
Applications can store messages in a
mailslot. The owner of the mailslot
can retrieve messages that are stored
there. These messages are typically
sent over a network to either a
specified computer or to all computers
in a specified domain. A domain is a
group of workstations and servers that
share a group name
.

They don't need a Windows domain, they work over a LAN.

DelphiPages has a nice run-down on doing IPC in Delphi, including mailslots.

--jeroen

夏末的微笑 2024-10-16 14:55:59

如果您想节省一些工作并使用现成的解决方案:

按上述顺序。最后两个列出的目的只是为了提供信息。

IMO 0MQ 这是最好的选择 - 它经过深思熟虑、轻量级、快速且可靠。

If you want save yourself some work and use ready solution:

in above order. Last two listed rather in informational purposes.

IMO 0MQ it's best bet - it's well-thought-out, lightweight, fast and reliable.

心如荒岛 2024-10-16 14:55:59

看起来像发布-订阅消息传递。 kbmMW 提供了一个。

Looks like publish-subscribe messaging. kbmMW offers one.

寂寞清仓 2024-10-16 14:55:59

关于使用 indy,例如在此演示中: indy10clieservr.sourceforge.net 或使用 TServerSocketTClientSocket

->现在有来自 INDY 的 x64 演示示例

About using indy, such as in this demo: indy10clieservr.sourceforge.net OR using the TServerSocket and TClientSocket package

-> now with x64 demo sample from INDY

旧时光的容颜 2024-10-16 14:55:59

要使其可靠地工作,需要做的工作比您想象的要多 - 大约需要 5% 的努力才能使其正常工作,并需要 95% 的努力才能确保其在所有情况下都能正常工作,包括网络中断等。如果您转到此处 (http://www.csinnovations.com/framework_delphi.htm) 你可以看到我是如何实现进程间通信的框架。 TCP 内容包含大约 10,000 行使用 Indy 组件的代码。

To get this working reliably is more work than you might think - about 5% effort to get it working, and 95% effort to ensure it works under all circumstances, including network dropouts, etc. If you go here (http://www.csinnovations.com/framework_delphi.htm) you can see how I implemented my inter-process communications framework. The TCP stuff comprises about 10,000 lines of code using the Indy components.

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