<p>I have a classic client/server (fat client and database) program written in Delphi 2006. When certain conditions are met in the client, I need to notify all the other clients very quickly. Up until now this has been done using UDP broadcasts, but this is no longer viable as clients now connect from outside the LAN and the UDP broadcast is limited to the local network. </p>

<p>I'm aware of the Indy libraries but am not really sure of which components to use and how to structure it. I'm guessing I'll need to have a server that the clients connect to which will receive and distribute the messages...? Any samples out there to get me started?</p>

<p>Are there any other component sets or technologies I should look at instead/as well?</p>

[{'answer_id': 58625, 'author': 'Jorge Córdoba', 'author_id': 2695, 'author_profile': 'https://Stackoverflow.com/users/2695', 'pm_score': 0, 'selected': False, 'text': '<p>You should be able to use Multicast UDP for the same purpose. The only difference will be to join the multicast group from every client.</p>\n\n<p><a href="http://en.wikipedia.org/wiki/IP_Multicast" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/IP_Multicast</a></p>\n\n<p><a href="http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol</a></p>\n\n<p><strong>Edit:</strong> Just to clarify, multicast let you join a given "group" associated to a multicast ip address. Any packet sent to that address will reach every client who has join the group</p>\n'}, {'answer_id': 58635, 'author': 'mj2008', 'author_id': 5544, 'author_profile': 'https://Stackoverflow.com/users/5544', 'pm_score': 3, 'selected': True, 'text': "<p>The simple answer is that the standard protocols available in Delphi (and other tools) don't allow for notification in reverse. I looked into this for a project where I wanted to use SOAP. They all assume client asks server, server responds and that's it. </p>\n\n<p>For me, the solution was the RemObjects SDK. This allows you to send notifications to clients, and the notification can have any data you like (just like the client to server). Myself I use the SuperTCP connection, but it works with others too. It can still offer a SOAP interface for clients that must use it, but for where you have control of both client and server it works extremely well. </p>\n"}, {'answer_id': 59559, 'author': 'Jim McKeeth', 'author_id': 255, 'author_profile': 'https://Stackoverflow.com/users/255', 'pm_score': 2, 'selected': False, 'text': '<p>There are a few really easy ways to do this with Delphi, although I am sure the RemObjects SDK works really well too.</p>\n\n<ol>\n<li>Have a central server that has a * TIdTCPServer listening* on it.  Then each client has a <em>TIdTCPClient</em> on it. They connect to the server and <strong>block on a read</strong> <em>waiting</em> for the <strong>server to write</strong>.  Once the server receives a notification via a listening socket it <em>broadcasts</em> to each of the waiting clients.  This is pretty much immediate notification of all the clients.  </li>\n<li>Have a central server that has a <strong>TIdTCPServer listenin</strong>g on it.  Then each client has a <strong>TIdTCPClient</strong> on it.  Those clients can <em>"ping"</em> the server to ask for updates at a regular interval (use a session token to maintain state).  The frequency of the interval determines how quick the notification will be.  When once one of the clients needs to notify the others, it just notifies the server.  The server then uses a <em>message queue</em> to make a list of all active client sessions and adds a notification for each.  Then the next time each of the clients connects it gives it the notification and remove it from the queue.</li>\n<li>Maintain a <em>session table</em> in the database where each client updates regularly that they have an active session, and removes itself when it disconnects.  You will need a maintenance process that removes dead sessions.  Then you have a <em>message queue table</em> that a client can write an update to with one row for each current active session.  Then the other clients can regularly ping that table to see if there are any pending notifications for its session, if there are it can read them, act on them and then remove them.</li>\n<li>Some sort of <em>peer to peer</em> approach were the clients are aware of each other through information in the database and then they connect directly to each other and notify or ask for notifications (depending on firewall and NAT configurations).  A little more complex, but possible.</li>\n</ol>\n\n<p>Obviously the choice of implementation will depend on your setup and needs.  Tunning will be necessary to achieve the best results.  </p>\n\n<p>The components you need for this are the <strong>TIdTCPServer</strong> (listener) and <strong>TIdTCPClient</strong> (sender).  Both of which are in the Indy libraries in Delphi.</p>\n'}, {'answer_id': 65703, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>ICS components from <a href="http://www.overbyte.be" rel="nofollow noreferrer">http://www.overbyte.be</a> are great.\na.) Better compatibility than Indy\nb.) PostCard ware\nGood examples and support. Use TClientSocket and TServerSocket</p>\n'}, {'answer_id': 563352, 'author': 'Fabricio Araujo', 'author_id': 10300, 'author_profile': 'https://Stackoverflow.com/users/10300', 'pm_score': 1, 'selected': False, 'text': "<p>FirebirdSQL project use the concept of notifications as being server-client connections that send a string to the client. For this, the db server uses an other port. And require the client to register it's interesting of receiving a certain type of notification through an API call.</p>\n\n<p>You could use the same idea.</p>\n"}, {'answer_id': 5736903, 'author': 'Silverio Diquigiovanni', 'author_id': 717938, 'author_profile': 'https://Stackoverflow.com/users/717938', 'pm_score': 0, 'selected': False, 'text': "<p>You can watch weonlydo wodVPN component which permit you to create a robust UDP hole punching and gain a port-forwading or a normal VPN (with a fornished network adapter) so you can connect two PC behind a NAT.</p>\n\n<p>I'm using this control for our communication program and works very fine.</p>\n"}, {'answer_id': 5737426, 'author': 'APZ28', 'author_id': 190837, 'author_profile': 'https://Stackoverflow.com/users/190837', 'pm_score': 1, 'selected': False, 'text': '<p>RabbitMQ should fit your bill. The server is free and ready to use. You just need a client side to connect, push/send out message and get/pull notified message</p>\n\n<p>Server: <a href="http://www.rabbitmq.com/download.html" rel="nofollow">http://www.rabbitmq.com/download.html</a>\nDo a google for client or implement yourself</p>\n\n<p>Cheers</p>\n'}]
['https://Stackoverflow.com/questions/58618', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1008/']