| 123456789101112131415161718192021222324252627282930 |
- #ifndef __BROADCAST_H__
- #define __BROADCAST_H__
- #include <QObject>
- #include <QJsonObject>
- #include <unistd.h>
- #include <arpa/inet.h>
- #include <sys/socket.h>
- class Broadcast : public QObject
- {
- Q_OBJECT
- public:
- explicit Broadcast(const int port, QObject *parent = nullptr);
- ~Broadcast();
- int write(const QJsonObject &json);
- protected:
- bool init(const int port);
- private:
- int sockfd;
- struct sockaddr_in broadcast_addr;
- int broadcast_enable = 1;
- };
- #endif // BROADCAST_H
|