Suggestions on writing a TCP IP messaging system (Client/Server) using Delphi 2010

天涯浪子 提交于 2019-12-07 09:42:43

问题


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.


回答1:


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




回答2:


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

  • 0MQ
  • STOMP
  • AMQP
  • XMPP

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.




回答3:


Looks like publish-subscribe messaging. kbmMW offers one.




回答4:


There's an instant message client from Aid Aim: http://www.aidaim.com/products/msgcommunicator/manual_instant-messaging-im-sdk/index.php




回答5:


To get this working reliably is more work than you might think - abut 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.




回答6:


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



来源:https://stackoverflow.com/questions/4521475/suggestions-on-writing-a-tcp-ip-messaging-system-client-server-using-delphi-20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!