
Originally Posted by
wysota
So what's the point of monitoring the socket? You don't even need the socket at all... you can use stdin/stdout to transfer all the data you need.
Each connection of the client and performance of process is processed in a separate stream:
{
return;
}
}
Server::~Server()
{
}
void Server::incomingConnection(int socketDescriptor)
{
FortuneThread *thread = new FortuneThread(socketDescriptor,this);
thread->start();
}
Server::Server(QObject *parent):QTcpServer(parent)
{
if (!listen(QHostAddress::Any,1715)) {
return;
}
}
Server::~Server()
{
}
void Server::incomingConnection(int socketDescriptor)
{
FortuneThread *thread = new FortuneThread(socketDescriptor,this);
thread->start();
}
To copy to clipboard, switch view to plain text mode
void FortuneThread::run()
{
Connection connection;
if(!connection.setSocketDescriptor(socketDescriptor))
{
emit error(connection.error());
return;
}
connect(&connection, SIGNAL(disconnected()), this, SLOT(deleteConnection()));
exec();
}
void FortuneThread::run()
{
Connection connection;
if(!connection.setSocketDescriptor(socketDescriptor))
{
emit error(connection.error());
return;
}
connect(&connection, SIGNAL(disconnected()), this, SLOT(deleteConnection()));
exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks