/****************************************************************************
**
** Copyright (C) 2024 Ivailo Monev
**
** This file is part of the QtNetwork module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QSOCKETSERVER_H
#define QSOCKETSERVER_H

#include <QtCore/qmetatype.h>
#include <QtNetwork/qsocketdevice.h>
#include <QtNetwork/qhostaddress.h>

QT_BEGIN_NAMESPACE

class QSocketServerPrivate;

class Q_NETWORK_EXPORT QSocketServer : public QObject
{
    Q_OBJECT
public:
    explicit QSocketServer(QObject *parent = nullptr);
    virtual ~QSocketServer();

    bool init(const QHostAddress &address, const quint16 port);
    bool init(const QString &name);

    bool listen();
    void close();

    quint16 socketPort() const;
    QHostAddress socketAddress() const;
    QString socketName() const;
    int socketDescriptor() const;
    QString errorString() const;

    int socketOption(const int option);
    bool setSocketOption(const int option, const int optionvalue);

Q_SIGNALS:
    void newConnection(QSocketDevice *device);

private:
    Q_PRIVATE_SLOT(d_func(), void _q_activated())

    Q_DISABLE_COPY(QSocketServer)
    Q_DECLARE_PRIVATE(QSocketServer)
};

QT_END_NAMESPACE

Q_DECLARE_METATYPE(QSocketDevice*)

#endif // QSOCKETSERVER_H
