http server application question lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- xinyiman · 2020-11-23 21:47 Hi, I have a question. I would like to create a "" (which I would later like to convert to CGI) that receives a text message via a POST call (and so far it's very easy) and forwards this message immediately to another client. Ex: client 1 sends "hello world" to my web server the web server sends the message "hello world" to client 2 (which was connected shortly before). Let it be clear, however, that it is not client 2 that asks the web server if there is a message for it, but it is the server itself that sends the message to the client. You say what can be done? ---------------------------------------------------------------------- lainz · 2020-11-23 22:42 WebSockets is what you're looking for. But there must be a connection established first between the second client and the server, so he knows is listening for future messages as far as I can understand. ---------------------------------------------------------------------- xinyiman · 2020-11-24 07:26 I probably haven't explained myself. Assume you have created an http server application with lazarus. Which has only one module and which has in turn only has the action called "index". Let's pretend that this program responds to the address "http://192.168.1.10:80/index" Now connect to that address and you will receive "Hello world" I want that in addition to you seeing the word hello world this is also sent to another client (for example if you are the ip 192.168.1.11 the message must also be received by the client 192.168.1.12). If I am not clear tell me that I will provide other more complete examples. ---------------------------------------------------------------------- Leledumbo · 2020-11-24 08:30 Use fphttpclient in the handler, make a good use of the passed TRequest instance to make the forwarded request. ---------------------------------------------------------------------- xinyiman · 2020-11-24 08:33 I do not understand what you mean. ---------------------------------------------------------------------- dogriz · 2020-11-25 07:26 Or you can make another small server on second client. ---------------------------------------------------------------------- egsuh · 2020-11-25 08:07 For server to send message to a client which did not send request, I heard that it needs streaming. Unforfunately I do not know how two. Several years ago Delphi demonstrated it can built messenger funciton --- you can make messenger like Facebook Messenger. Is that what you want? I don't know whether it is possible with Lazarus. ---------------------------------------------------------------------- PierceNg · 2020-11-26 00:41 Quote from: xinyiman on November 24, 2020, 08:26:20 amLet's pretend that this program responds to the address "http://192.168.1.10:80/index" Now connect to that address and you will receive "Hello world" I want that in addition to you seeing the word hello world this is also sent to another client (for example if you are the ip 192.168.1.11 the message must also be received by the client 192.168.1.12). But the other client 192.168.1.12 ought to have been connected to the server for that to happen, no? Otherwise, you are expecting 192.168.1.12 to be running a server program too. As the previous reply said, websockets is what you are looking for. This is listed on the wiki page: https://github.com/Warfley/LazWebsockets