[PD-dev] mrpeach/tcpserver one last lingering bug
martin.peach at sympatico.ca
Thu May 6 05:57:49 CEST 2010
Ivica Ico Bukvic wrote:
> please send me a brief flow of functions "broadcast" calls so that I can figure out where to look for potential fixes/improvements.
Well broadcast calls tcpserver_send_bytes() once for each connected client.
tcpserver_send_bytes() fills a buffer from the input message and spawns
a thread running tcpserver_send_buf_thread() to send the content
whenever the buffer is full or the message is completely converted from
atoms to bytes.
I think as long as your messages all fit in a single buffer it's a lot
easier. The snag is that tcpserver_send_bytes() can fill the buffer more
than once for each message if the message is > 64k.
Apart from that, to skip redundant conversion of atom to byte and
multiple thread creation, I would make a single buffer from the input
and pass it to a single thread that sends the same buffer to each
Since the current tcpserver_send_bytes() can also be used to send very
long files, it may be better to make a dedicated broadcast function that
only does small packets (less than 65536 bytes), as broadcasting
megabytes to many clients will no doubt peg the machine.
More information about the Pd-dev