help / color / mirror / Atom feed
From: Emmanuel Briot <>
Subject: Re: Broadcast / iterate to all Connection objects via Simple Components?
Date: Sun, 12 Feb 2023 23:28:26 -0800 (PST)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <trvrhv$4es9$>

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.


  reply	other threads:[~2023-02-13  7:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 20:29 Broadcast / iterate to all Connection objects via Simple Components? A.J.
2023-02-08  8:55 ` Dmitry A. Kazakov
2023-02-08  9:55 ` Jeffrey R.Carter
2023-02-13  7:28   ` Emmanuel Briot [this message]
2023-02-13  8:30     ` Dmitry A. Kazakov
2023-02-13  8:44       ` Emmanuel Briot
2023-02-13 10:55         ` Dmitry A. Kazakov
2023-02-13 11:07           ` Emmanuel Briot
2023-02-13 11:57             ` Dmitry A. Kazakov
2023-02-13 13:22               ` Niklas Holsti
2023-02-13 15:10                 ` Dmitry A. Kazakov
2023-02-13 16:26                   ` Niklas Holsti
2023-02-13 19:48                     ` Dmitry A. Kazakov
2023-02-15  9:54                       ` Niklas Holsti
2023-02-15 10:57                         ` Dmitry A. Kazakov
2023-02-15 18:37                           ` Niklas Holsti
2023-02-19  1:27                             ` A.J.
2023-02-19  8:29                               ` Dmitry A. Kazakov
2023-02-19 14:37                               ` Niklas Holsti
2023-02-13 15:43                 ` J-P. Rosen
2023-02-13 16:40             ` Jeremy Grosser <>
2023-02-13 20:33 ` Daniel Norte de Moraes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox