I have tried so many things but still problem persists.
I can see that server is started and can connect using telnet. But it does not invoke new connection slot. What seems to be wrong?
main.cpp
int main(int argc, char *argv[])
{
core = new QGCCore(firstStart, argc, argv);
val = core->exec();
}
int main(int argc, char *argv[])
{
core = new QGCCore(firstStart, argc, argv);
val = core->exec();
}
To copy to clipboard, switch view to plain text mode
QGCCore.cpp:
QGCCore
::QGCCore(bool firstStart,
int &argc,
char* argv
[]) : QApplication(argc, argv
),
restartRequested(false),
welcome(NULL)
{
Server s;
s.listen();
}
QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc, argv),
restartRequested(false),
welcome(NULL)
{
Server s;
s.listen();
}
To copy to clipboard, switch view to plain text mode
server.cpp
#include "server.h"
#include <QTcpServer>
#include <QTcpSocket>
#include <cstdio>
#include <QDebug>
{
connect(server, SIGNAL(newConnection()),
this, SLOT(on_newConnection()));
qDebug() << "Server instance created";
}
void Server::listen()
{
qDebug() << "Server listening to 1234";
}
void Server::on_newConnection()
{
qDebug() << "New connection made!";
}
#include "server.h"
#include <QTcpServer>
#include <QTcpSocket>
#include <cstdio>
#include <QDebug>
Server::Server(QObject *parent) :
QObject(parent)
{
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()),
this, SLOT(on_newConnection()));
qDebug() << "Server instance created";
}
void Server::listen()
{
server->listen(QHostAddress::Any, 1234);
qDebug() << "Server listening to 1234";
}
void Server::on_newConnection()
{
qDebug() << "New connection made!";
}
To copy to clipboard, switch view to plain text mode
Bookmarks