We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server
//new QTcpServer* mp_TCPServer = new QTcpServer();
//listen mp_TCPServer->listen(QHostAddress::Any, port)
//SIGNAL:newConnection() conncet signal and slot functions newConnection()->
//>nextPendingConnection mp_TCPSocket = mp_TCPServer->nextPendingConnection();
//SIGNAL:readyRead receive data connect(mp_TCPSocket, SIGNAL(readyRead()), this, SLOT(ServerReadData()));
//write int sendRe = mp_TCPSocket->write(sendMsgChar, strlen(sendMsgChar));
client
//new QTcpSocket *mp_clientSocket = new QTcpSocket();
//connect mp_clientSocket->connectToHost(ip, port);
//receive SIGNAL(readyRead())->ClientRecvData() connect(mp_clientSocket, SIGNAL(readyRead()), this, SLOT(ClientRecvData())); ClientRecvData() { char recvMsg[1024] = {0}; int recvRe = mp_clientSocket->read(recvMsg, 1024); if(recvRe == -1) { QMessageBox::information(this, "QTcpSocket", "connect server data fail!"); return; } QString showQstr = recvMsg; ui->m_recvTextEdit_2->setText(showQstr); } SIGNAL(connect())
//write ->write()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
//new
QTcpServer* mp_TCPServer = new QTcpServer();
//listen
mp_TCPServer->listen(QHostAddress::Any, port)
//SIGNAL:newConnection() conncet signal and slot functions
newConnection()->
//>nextPendingConnection
mp_TCPSocket = mp_TCPServer->nextPendingConnection();
//SIGNAL:readyRead receive data
connect(mp_TCPSocket, SIGNAL(readyRead()), this, SLOT(ServerReadData()));
//write
int sendRe = mp_TCPSocket->write(sendMsgChar, strlen(sendMsgChar));
//new
QTcpSocket *mp_clientSocket = new QTcpSocket();
//connect
mp_clientSocket->connectToHost(ip, port);
//receive
SIGNAL(readyRead())->ClientRecvData()
connect(mp_clientSocket, SIGNAL(readyRead()), this, SLOT(ClientRecvData()));
ClientRecvData()
{
char recvMsg[1024] = {0};
int recvRe = mp_clientSocket->read(recvMsg, 1024);
if(recvRe == -1)
{
QMessageBox::information(this, "QTcpSocket", "connect server data fail!");
return;
}
QString showQstr = recvMsg;
ui->m_recvTextEdit_2->setText(showQstr);
}
SIGNAL(connect())
//write
->write()
The text was updated successfully, but these errors were encountered: