I was trying to use the synchronous connection mechanism of QTcpServer to implement a server. My code is very simple one. PFB.
//////
MainScreen::MainScreen(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainScreen)
{
ui->setupUi(this);
server = new QTcpServer();
}
int MainScreen::waitForConnection()
{
bool timeOut = 0;
if (server->listen(QHostAddress("192.168.70.30"), 10000))
{
quint16 port = server->serverPort();
qDebug() << "Server : "<< (server->serverAddress()).toString() << "Port : "<< port;
server->waitForNewConnection(-1, &timeOut);
}
return 0;
}
//main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainScreen w;
w.waitForConnection();
return a.exec();
}
And I'm trying to connect to the server from a Linux client application(C). Unfortunately I'm not getting any connection in my server. Do I need to do something else to work on synchronous connection? Thanks in advance
PFB result of netstat
netstat -np TCP
Active Connections
Proto Local Address Foreign Address State
TCP 127.0.0.1:62908 127.0.0.1:62909 ESTABLISHED
TCP 127.0.0.1:62909 127.0.0.1:62908 ESTABLISHED
TCP 192.168.70.89:62817 10.47.1.10:49224 ESTABLISHED
TCP 192.168.70.89:62924 10.47.1.101:3128 ESTABLISHED
TCP 192.168.70.89:63209 10.47.1.101:3128 TIME_WAIT
TCP 192.168.70.89:63213 10.47.1.101:3128 TIME_WAIT
TCP 192.168.70.89:63264 10.47.1.101:3128 TIME_WAIT
TCP 192.168.70.89:63265 10.47.1.101:3128 TIME_WAIT
TCP 192.168.70.89:63266 10.47.1.11:8014 CLOSE_WAIT
TCP 192.168.70.89:63267 111.221.112.54:995 TIME_WAIT
TCP 127.0.0.1:62908 127.0.0.1:62909 ESTABLISHED