我想这样做
对于服务器:
QTcpServer qtp;
qtp.listen(QHostAddress::Any, 1440);
qtp.readFromClient(); //What is the name of the method to read the byte from a client ???
qtp.close();
对于客户
QTcpClient client;
client.connect("127.0.0.1", 1440);
client.sendData(myString); // What is the name of the method to do this ???
client.close();
我没有在QTcpServer中找到方法名来检索数据,而在QTcpClient中找不到方法名来发送数据。有什么方法可以做到这一点?
答案 0 :(得分:0)
您可以查看阅读文档的所有可用方法。在this link中,有QTcpSocket继承的QAbstractSocket类的文档。
无论如何,您要使用write()
方法发送数据,您可以检查数据是否可以通过bytesAvailable()
阅读,并使用read()
或readData()
读取数据。这些las方法是从QIODevice类继承并重新实现的,您也可以在documentation中找到。