Code refactoring

Abstract the same logic between st_tcp_client and st_udp_client to a new
class st_client_base;
Abstract the same logic between st_tcp_socket and st_udp_socket to a new
class st_socket;
Add helper function safe_send_msg and safe_broadcast_msg;
Add support to suspend dispatching msgs in runtime.