From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a37:aa03:0:b0:730:f188:8ccd with SMTP id t3-20020a37aa03000000b00730f1888ccdmr217450qke.75.1675801780863; Tue, 07 Feb 2023 12:29:40 -0800 (PST) X-Received: by 2002:a05:6871:5d3:b0:15f:24e3:c98a with SMTP id v19-20020a05687105d300b0015f24e3c98amr50605oan.201.1675801780159; Tue, 07 Feb 2023 12:29:40 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 7 Feb 2023 12:29:39 -0800 (PST) Injection-Info: google-groups.googlegroups.com; posting-host=2600:4040:7208:8d00:bcc9:865c:3fba:49c4; posting-account=es6tdQoAAABG0JD-zg4XEg34h5fepyKP NNTP-Posting-Host: 2600:4040:7208:8d00:bcc9:865c:3fba:49c4 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <392dd5d3-4df1-403f-b703-ee6f750dbc81n@googlegroups.com> Subject: Broadcast / iterate to all Connection objects via Simple Components? From: "A.J." Injection-Date: Tue, 07 Feb 2023 20:29:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2874 Xref: reader01.eternal-september.org comp.lang.ada:64901 List-Id: Hello everyone, In an effort to better learn network programming in Ada, I've been working = through the Protohacker Challenges (https://protohackers.com/), and the cur= rent challenge (number 3) is to create a chat server. I am using a TCP Connections Server with Simple Components, specifically a = Connection_State_Machine, but I've run into a problem.=C2=A0 I'm trying to = send a message received via "procedure Process_Packet (Client : in out Serv= er_Connection)" to all connected Clients. My (potentially incorrect) thought on how to accomplish this is to iterate = through all of the clients currently connected, and use Send to send the me= ssage received to those clients.=C2=A0 I've been struggling with how to act= ually do this though, since I couldn't use=C2=A0"function Get_Clients_Count= (Listener : Connections_Server) return Natural" from within Process_Packet= s. Another thought I had could be to just place every message received in a ce= ntral queue, and then once all of the packets have been received, to then p= rocess that queue and send the results to every connected client. I tried overriding "procedure On_Worker_Start (Listener : in out Connection= s_Server)", thinking that I could use it to read such a queue, but it never= seemed to be called from within my program and I'm still unsure how to ite= rate through the Connection objects anyway. Am I approaching this the right way, or am I missing something very obvious= ?=C2=A0 I've read the test files that came with Simple Components, includin= g the data server but couldn't see a way to get each client to interact wit= h each other. If I didn't explain this well enough, please let me know, I'= ll be happy to clarify. Kind regards, AJ.