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:bbc5:0:b0:723:b9fa:2196 with SMTP id l188-20020a37bbc5000000b00723b9fa2196mr2043975qkf.146.1676273306878; Sun, 12 Feb 2023 23:28:26 -0800 (PST) X-Received: by 2002:a05:6870:580d:b0:163:31fe:9bd with SMTP id r13-20020a056870580d00b0016331fe09bdmr3363109oap.129.1676273306631; Sun, 12 Feb 2023 23:28:26 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Sun, 12 Feb 2023 23:28:26 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=88.160.66.39; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH NNTP-Posting-Host: 88.160.66.39 References: <392dd5d3-4df1-403f-b703-ee6f750dbc81n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Broadcast / iterate to all Connection objects via Simple Components? From: Emmanuel Briot Injection-Date: Mon, 13 Feb 2023 07:28:26 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2699 Xref: reader01.eternal-september.org comp.lang.ada:64906 List-Id: I am not sure how familiar you are with Network programming in general (not just as it would be done in Ada). Using a blocking Send could actually kill your performance. You mentioned you would be sending a message to one client after another. Imaging one of the client has small socket buffers, and is busy doing something else at the moment so not reading your message immediately. If you are sending a large message, your server would only be able to send part of the message, then it would block until the client has read enough that there is space again in the socket buffers to send the rest of the message. That could take ... days ? In the meantime, you server is not doing anything else, and no other client gets send anything... Instead, you need to use non-blocking sockets. When Send returns, it has sent whatever it could for the moment. You then need to monitor the socket (and all other similar ones) using something like select (which is limited to sockets < 1024, so pretty useless for an actual server in practice), poll (better version of select) or epoll (the best in my opinion). I have written a similar server that has 25000 concurrent clients, and serving them all with 10 worker tasks. That would never fly with blocking sockets. A similar approach when receiving messages from clients, by the way. The message might have sent only part of its message, so you need to give up temporarily, and come back to it when poll tells you there is something new to read. Emmanuel