Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么QT-tcpsocket.write不起作用?_Python_Sockets_Qt4 - Fatal编程技术网

Python 为什么QT-tcpsocket.write不起作用?

Python 为什么QT-tcpsocket.write不起作用?,python,sockets,qt4,Python,Sockets,Qt4,以下是Clinet的代码: QString text = ui->lineEdit->text(); if(text.isEmpty()) return; tcpsocket->waitForBytesWritten(300); tcpsocket->write(text.toStdString().c_str(),text.length()); qDebug("State:%d\n",tcpsocket->state()); qDebug("%d\n",t

以下是Clinet的代码:

QString text = ui->lineEdit->text();
if(text.isEmpty())
    return;
tcpsocket->waitForBytesWritten(300);
tcpsocket->write(text.toStdString().c_str(),text.length());
qDebug("State:%d\n",tcpsocket->state());
qDebug("%d\n",tcpsocket->flush());
ui->lineEdit->clear();
状态为3,冲洗返回1 但是为什么我的服务器不能收到消息?
我的服务器是由py编写的,我可以成功地远程登录它

为什么在写入之前要等待写入的字节?也许您的服务器等待新行字符?代码Painiters是正确的!非常感谢。