#ifndef QBINDTCPSOCKET_H
#define QBINDTCPSOCKET_H

#define DEF_SERVER_IP         "192.168.16.253"
#define DEF_SERVER_PORT     5000
#define DEF_LOCAL_IP            ""
#define DEF_LOCAL_PORT       5001


#include <QTcpSocket>

class QBindTcpSocket : public QTcpSocket
{

public:
    QBindTcpSocket(QObject *parent = 0);
    virtual ~QBindTcpSocket();

public:
    int bindAddrAndPort(QString localAddr, quint16 localPort);
};

#if(1)
class TcpConnectDetect : public QObject
{
    Q_OBJECT
public:
    explicit TcpConnectDetect(QObject *parent = NULL);
    virtual ~TcpConnectDetect();

signals:
    void siConnectSta(int sta);          // 网络连接信号
public:

public slots:
    void detectStart();
    int connectDetect();

private:
    QBindTcpSocket * m_pDetectSocket;

public:
    void setIpAndPort(QString localip, quint16 localport, QString serverip, quint16 serverport);

private:
    QString m_localip;
    quint16 m_localport;
    QString m_serverip;
    quint16 m_serverport;
};
#endif

#endif // QBINDTCPSOCKET_H
