The question about how to make a broadcast socket is solved. Firstly, create a socket with SOCK_DGRAM;
secondly, set the socket's socket level and SO_BROADCAST option to 1. So, you can use it to broadcast your
messages.
So, I constructed a thread class specially in order to broad cast a message at intervals. For convenience,
I also wrote some auxiliary functions and create a message object hierarchical classes. The root of that
message object is just used a interface in which I define message type contants and some methods must be
implemented by it's son, grandson, or grand-grand-son.
Now only the TextMsgObj class was just implemented. This class has two special methods: serialize(),
deserialize(). They is used for serialization of a instance. But my defined serialization is just to
translate a message object into a string representation. The reason is that I can use sendto() send that.
The str() function can translate a object into a human readable string. The eval() function can retore
a object from a string.