Broadcast to all clients of wxSocketServer

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
In need of some credit
In need of some credit
Posts: 3
Joined: Tue May 09, 2006 6:59 pm

Broadcast to all clients of wxSocketServer

Post by ryandeluz » Tue May 09, 2006 7:12 pm

Hi all,

How do I send messages to all clients that are connected to my wxSocketServer?

I am modifying the wxSocketServer sample for my own use. My socket application is basically a way for me transmit data from my wxWidgets application to an arbitrary (probably 15 or less) other open windows of flash, directory or other c++ applications. This will be a way for me to make public incoming data streams from USB devices that read heart rate, skin sweat, etc., in a cross platform manner.

It seems like a could make a list that adds and removes client sockets, and iterates through the list to send messages to each client. I will be sending data to all clients at a rate of 30x per second, so I want this to be as efficient as possible.

Is using a list the best way to achieve this?

Is there any "sendall" (broadcast) command in wxsocketserver?

Is the list of sockets attached to the server already stored somewhere in the socket server?

I have examined the samples (I am building from them) and have the wxWidgets books, but I cannot find any information about sending data to all attached clients.

All help is appreciated,


Ryan Deluz
[email protected]

Earned a small fee
Earned a small fee
Posts: 23
Joined: Tue Jul 11, 2006 1:36 pm
Location: Poland, Warsaw

Post by krzysiek_t » Thu Jul 05, 2007 8:37 am

At first - there is nothing like broadcast in TCP connections. wxServerSocket is only "listening" socket. After it accepts a connections, the incoming connection is connected to newly created socket bound to another port.

You may be interested in multicast - but it's not so simple and it seems wxWidgets doesn't support this feature now. Even berkeley sockets (that is: normal socket C library) don't support it.

A solution with list of sockets is the best you can do I think.

Good luck!

Post Reply