4

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.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
IElite
  • 1,818
  • 9
  • 39
  • 64
  • 6
    Sounds like [IP Multicasting](http://en.wikipedia.org/wiki/IP_multicast) – Kenneth Cochran Dec 23 '10 at 19:28
  • 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. – IElite Dec 23 '10 at 20:51
  • @Shane I've moved your note to the question, where it should be stated (instead of comments). – Eugene Mayevski 'Callback Dec 24 '10 at 08:03
  • Thank you all for your answers! So, what do you all think about using indy, such as in this demo: http://indy10clieservr.sourceforge.net/ OR using the TServerSocket and TClientSocket packages ????? – IElite Dec 26 '10 at 22:58
  • 1
    @Shane TClientSocket and TServerSocket are outdated and obsolete. Indy was taken as a replacement. If you plan a long-term project, I'd suggest creating simple wrappers for Winsock yourself. It's not that hard and you don't depend on third-party code of questionable quality. – Eugene Mayevski 'Callback Dec 27 '10 at 11:50
  • @codeelegance: It is, and i think that is what i was looking for. Do you know much about implementing this in Indy, using the TIdIPMCastClient/Server component? I have been thinking that is could be done with Indy and i am just waiting for someone to give me a little better direction. If you have more to offer, please post as an answer - thanks! – IElite Dec 27 '10 at 19:08
  • Sorry, I'm familiar with the concept of ip multicasting but I've never attempted to implement it (which is why I didn't try to answer the question directly). Unfortunately ip multicasting doesn't guarantee packet delivery. [PGM](http://tools.ietf.org/rfcmarkup?doc=3208) does but it is still experimental. Any number of ESB's could handle this but that may be overkill. – Kenneth Cochran Dec 27 '10 at 21:41

6 Answers6

4

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

Community
  • 1
  • 1
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • 3
    Mailslots don't guarantee delivery and have some other side effects, so they are not the best option. In OP's case this is claer pub-sub mechanism with dedicated server, and TCP would work fine. Yet, proper pub-sub with serializing of messages etc. is a non-trivial task. – Eugene Mayevski 'Callback Dec 24 '10 at 09:47
  • thanks for the remark; I added the named pipes portion because of it. – Jeroen Wiert Pluimers Dec 24 '10 at 10:45
3

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.

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
g2mk
  • 509
  • 3
  • 13
0

Looks like publish-subscribe messaging. kbmMW offers one.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • i would like to write this myself, as i stated in my question, instead of relying on commercial components. Im not quite sure that set you suggested would even do what i want to do - thanks for replying though – IElite Dec 23 '10 at 20:34
  • 1
    @Shane "write a system" is quite a broad phrase. As for kbmMW - did you really check it? IF you are going to write your own, then successful implementation would be a great sample for you to start. – Eugene Mayevski 'Callback Dec 24 '10 at 07:55
0

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

Darian Miller
  • 7,808
  • 3
  • 43
  • 62
  • sorry, not really looking for instant messaging, or chatting. Im looking for a alert/messaging system (one i can build using tcp ip). To alert users with important messages. – IElite Dec 23 '10 at 20:32
  • I should mention, a system where users can not reply to each other! – IElite Dec 23 '10 at 21:33
  • @Darian Miller I already insatalled msgcommunicator v11 for my delphi XE8. I'd like to make Client/Server Chat using internet. I like this component but on a net I couldn't find example for Client/Server, I don't have any idea, how to use? could you provide me simple example for msgcommunicator Client/Server. Thanks in Advance! – Alex Kirov Mar 29 '17 at 07:06
  • @AlexKirov sorry, I do not. This was a long time ago - if they aren't providing support these days, I wouldn't use them. Perhaps try: http://www.imcomponents.com/ivc.htm – Darian Miller Mar 30 '17 at 14:39
0

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.

Marcello B.
  • 4,177
  • 11
  • 45
  • 65
Misha
  • 1,816
  • 1
  • 13
  • 16
0

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

Echilon
  • 10,064
  • 33
  • 131
  • 217
FranzB
  • 1