how to make tcp server listen to a specific port using QTcpServer
i tried using QHostAddress to initialse my QTcpServer object but whenever i start the server i get an error unable to start the server.
this is the code for initialising the server
Code:
tcpserver->listen(hostadd,23456);
if (!tcpserver->listen()) {
QMessageBox::critical(this, tr
("Fortune Server"), tr
("Unable to start the server: %1.").
arg(tcpserver
->errorString
()));
close();
return;
}
when i compile i get no error.
is this correct??? please help me
thanx in advance
Re: how to make tcp server listen to a specific port using QTcpServer
Shoudn't it be:
Code:
if (!tcpserver->listen(hostadd,23456)) {
QMessageBox::critical(this, tr
("Fortune Server"), tr
("Unable to start the server: %1.").
arg(tcpserver
->errorString
()));
close();
return;
}
You were checking the return value of the wrong call to listen..
HIH
Johannes