I wanna develop a http server using muti-thread,during the communication connections,which some must keep-alive.
how the plan it.
or someone give me the source code with explainatons..
in addition,
see the defination if class timeserver
Code:
void timeserver:::incomingConnection(socketdescriptor,0); { TimeThread *thread = new TimeThread(socketDescriptor,0); connect(thread,SIGNAL(finished()),dlg,SLOT(showResult()),Qt::QueuedConnection); connect(thread,SIGNAL(finished()),thread,SLOT(deletelater()),Qt::DirectConnection); thread->start(); }
Code:
defination of class TimeThread void TimeThread::run() { if(!socket->setSocketDescriptor(socketDescriptor)) { return; } socket->write("aaa"); connect(socket,SIGNAL(readyRead()),this,SLOT(read()));// never exec the read() function when the client has sent the data, why? } void TimeThread::read() { qDebug() << "reading data"; }
as u see,I can only send data to client, how can i receive data from client,where should the slot function set?//Code:
connect(socket,SIGNAL(readyRead()),this,SLOT(read()));
