title: Unable to establish WiFi connection between client and server in qt
body: <p>I'm developing an app to connect 2 devices (one as server, the other as client)so they can communicate with each other (i.e send from one of them and receive in the other one). These 2 devices are connected to the same WiFi. For test (on 2 windows laptops) I've made an installer file from the client code, installed and run it on the second device. But the communication is not established. Where is the problem?</p>
  
  <p>Is there any setting that I have to do?</p>
  
  <p>Note: I've run the app (both server and client) on my laptop and it worked. But for 2 laptops it didn't!</p>
  
  <p>Here is my server.cpp:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QTcpServer&gt;
  #include &lt;QTcpSocket&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      _server = new QTcpServer(this);
  
      _server-&gt;listen(QHostAddress::Any,2000);
      statusBar()-&gt; showMessage("listening...");
     connect(_server,SIGNAL(newConnection()),this, SLOT(newConnection()));
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::newConnection()
  {
    _socket =
          _server-&gt;nextPendingConnection();
    connect(_socket, SIGNAL(readyRead())
            ,this ,SLOT(readData()));
    ui-&gt;label-&gt;setText("connection stablished");
    statusBar()-&gt;showMessage("");
  
  
  }
  void MainWindow::readData()
  {
    QByteArray ba = _socket-&gt;readAll();
    QString str(ba);
    ui-&gt;plainTextEdit-&gt;appendPlainText(str);
  
  }
  </code></pre>
  
  <p>and the client.cpp:</p>
  
  <pre><code>    #include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QTcpSocket&gt;
  #include &lt;QHostAddress&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      ui-&gt;progressBar-&gt;hide();
      _socket = new QTcpSocket(this);
  
      connect(_socket,SIGNAL(connected())
              ,this,SLOT(connectToHost()));
  
  
  }
  
  //127.0.0.1 == localhost
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::connectToHost()
  {
      ui-&gt;progressBar-&gt;hide();
      ui-&gt;btn_send-&gt;setEnabled(true );
  
  }
  
  void MainWindow::on_btn_connect_clicked()
  {
      ui-&gt;progressBar-&gt;show();
       QHostAddress address("127.0.0.1");
      _socket -&gt; connectToHost(address,2000);//inja darkhast connection ersal mishe.
  
  }
  
  void MainWindow::on_btn_send_clicked()
  {
  
      QByteArray  data = ui-&gt;LED_send_text
              -&gt;text().toLocal8Bit();
      _socket-&gt;write(data );
  }
  </code></pre>