I dont know why, but if I set the conexion between server and client first and then I call the function startSerialPort(), the reading speed is the normal. But this method just works with the first conexion. The second conexion already experiment the decrease of the reading speed.
void MyServer::startSerialPort()
{
mipuerto2 = new MySerialPort;
msgRec = new MensajeRecibido;
msgSent = new MensajeEnviar;
connect(mipuerto2, SIGNAL(msgChanged(QByteArray*)), this, SLOT(getMens(QByteArray*)));
connect(mipuerto2, SIGNAL(msgChanged(QByteArray*)), this, SLOT(idMensaje(QByteArray*)));
connect(msgSent, SIGNAL(tienesMensaje(QString*)), this, SLOT(setRecibido(QString *)));
mipuerto2->openSerialPort();
}
qDebug()<<socketDescriptor<<"Connecting... ";
socket = new MySocket(socketDescriptor);
controlador++;
QThread *thread = new QThread;
qDebug()<<thread->currentThreadId();
connect(this, SIGNAL(mensChanged(QByteArray*)), socket, SLOT(getMsg(QByteArray*)));
connect(socket, SIGNAL(mensajeEnviarSocket(QByteArray*)), this, SLOT(sendMens(QByteArray*)));
connect(socket, SIGNAL(disconnected()),thread, SLOT(quit()) );
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(thread, SIGNAL(started()), socket, SLOT(funcionamiento()));
connect(socket, SIGNAL(disconnected), this, SLOT(desconectar()));
socket->moveToThread(thread);
thread->start();
if(controlador==1){
startSerialPort();
}else if (controlador>1) {
mipuerto2->closeSerialPort();
delete mipuerto2;
startSerialPort();
}