Hi all!
I have no idea what's the (hell) is going on.
The simplest test...

SocketTest::SocketTest()

{

  mSocket=new QTcpSocket(this);

  QObject::connect(mSocket, SIGNAL(hostFound()), this, SLOT(onHostFound()));

  QObject::connect(mSocket, SIGNAL(connected()), this, SLOT(onConnected()));

  QObject::connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)),

                   this, SLOT(onError(QAbstractSocket::SocketError)));

}


void SocketTest::start()

{

  mSocket->connectToHost(QHostAddress("1.1.1.1"), 2000);

}


void SocketTest::onHostFound()

{

  qDebug()<<"OnHostFound"<<mSocket->state();

}


void SocketTest::onConnected()

{

  qDebug()<<"OnConnected"<<mSocket->state();

}


void SocketTest::onError(QAbstractSocket::SocketError Error)

{

  qDebug()<<"OnError"<<Error;

}


And socket is connected!!!

The problem is that socket connected and signal emmited.

Only then after couple of seconds program received error "Remote host closed"


On Linux and Android all ok.


Qt 5.5 5.6, WindowsXP_32, mingw32




-- 
Oleg Shalnev  (Kalpa Knowledge Integration Initiative)
----------------------------------------------
mailto: o...@kalpa.ru
skype:  oleg_shalnev
cell    :  +79111603306
cell    :  +79187417217

#include <QCoreApplication>
#include "sockettest.h"

int main(int argc, char *argv[])
{
  QCoreApplication App(argc, argv);

  SocketTest tsocket;
  tsocket.start();

  return App.exec();
}
#include "sockettest.h"
#include <QHostAddress>

SocketTest::SocketTest()
{
  mSocket=new QTcpSocket(this);
  QObject::connect(mSocket, SIGNAL(hostFound()), this, SLOT(onHostFound()));
  QObject::connect(mSocket, SIGNAL(connected()), this, SLOT(onConnected()));
  QObject::connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)),
                   this, SLOT(onError(QAbstractSocket::SocketError)));
}

void SocketTest::start()
{
  mSocket->connectToHost(QHostAddress("192.168.1.2"), 2000);
}

void SocketTest::onHostFound()
{
  qDebug()<<"OnHostFound"<<mSocket->state();
}

void SocketTest::onConnected()
{
  qDebug()<<"OnConnected"<<mSocket->state();
}

void SocketTest::onError(QAbstractSocket::SocketError Error)
{
  qDebug()<<"OnError"<<Error;
}
#ifndef SOCKETTEST_H
#define SOCKETTEST_H
#include <QTcpSocket>
#include <QDebug>

class SocketTest : public QObject
{
  Q_OBJECT
protected:
  QTcpSocket *mSocket;

public:
  SocketTest();
  void start();

protected slots:
  void onHostFound();
  void onConnected();
  void onError(QAbstractSocket::SocketError Error);

};

#endif // SOCKETTEST_H
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to