C++ (Qt)class Replyer: public QObject{ Q_OBJECTpublic: Replyer(QObject *parent = 0) :QObject(parent) {} private: QList<QTcpSocket*> mClients; void reply(QString message); public slots: void newConnection(int descriptor); private slots: void readData();}; void Replyer::newConnection(int descriptor){ QTcpSocket *client = new QTcpSocket(this); if(client->setSocketDescriptor(descriptor)) { connect(client, SIGNAL(readyRead()), SLOT(readData())); mClients.append(client); } else { client->deleteLater(); }} void Replyer::readData(){ QTcpSocket *client = qobject_cast<QTcpSocket*>(sender()); if(client) { //read data from socket reply(...); }} void Replyer::reply(QString message){ foreach(QTcpSocket* client, mClients) { //send data to clients }}