File indexing completed on 2024-06-16 03:57:07

0001 /*
0002  * servsock.h - simple wrapper to QServerSocket
0003  * Copyright (C) 2003  Justin Karneges
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * either version 2
0009    of the License, or (at your option) any later version.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0019  *
0020  */
0021 
0022 #ifndef CS_SERVSOCK_H
0023 #define CS_SERVSOCK_H
0024 
0025 #include <QtCore>
0026 #include <QtNetwork>
0027 
0028 // CS_NAMESPACE_BEGIN
0029 
0030 class ServSock : public QObject
0031 {
0032     Q_OBJECT
0033 public:
0034     ServSock(QObject *parent=0);
0035     ~ServSock() override;
0036 
0037     bool isActive() const;
0038     bool listen(quint16 port);
0039     void stop();
0040     int port() const;
0041     QHostAddress address() const;
0042 
0043 signals:
0044     void connectionReady(int);
0045 
0046 private slots:
0047     void sss_connectionReady(int);
0048 
0049 private:
0050     class Private;
0051     Private *d;
0052 };
0053 
0054 class ServSockSignal : public QTcpServer
0055 {
0056     Q_OBJECT
0057 public:
0058     ServSockSignal(QObject *parent = 0);
0059 
0060 signals:
0061     void connectionReady(int);
0062 
0063 protected:
0064     // reimplemented
0065     void incomingConnection(int socketDescriptor);
0066 };
0067 
0068 // CS_NAMESPACE_END
0069 
0070 #endif