View Full Version : why can't i write some string to the socket
succulent_lily
2nd December 2008, 09:33
when i run the code ,it exec correctly
codes:
QBuffer* buffer = new QBuffer(this);
buffer->open(QIODevice::ReadWrite);
qint64 bytes = buffer->write(this->readAll());
buffer->seek(buffer->pos() - bytes);
while (buffer->canReadLine())
{
QByteArray line = buffer->readLine();
write(line);
}
but when i write("xxxxxxx"),or
QString s="xxxxxx"
write(s.toLatin1());
write(s.Ascii());
write(s.toLatin1().data());
..........................
i can't write successlly,who can help me
muellerp
2nd December 2008, 09:38
qint64 bytes = buffer->write(this->readAll());
what object is "this->"
wysota
2nd December 2008, 13:51
What do you mean you can't write? The application doesn't compile, it returns some error, nothing is sent from the socket or nothing is received on the other side of the connection?
succulent_lily
3rd December 2008, 01:00
what object is "this->"
"this->" means the socket
What do you mean you can't write? The application doesn't compile, it returns some error, nothing is sent from the socket or nothing is received on the other side of the connection?
thanks for your help
i wasn't explain the problem complicitly
this is the server code,the server can receive the client's message which send by socket,and give the message to the client back.
in my pc,it is run correctly.
but when the server received the client's message ,i want to send something else string back,such as"xxxxxxx",it can't run.
that is my problem
succulent_lily
3rd December 2008, 09:19
Qt Code:
QByteArray line2("abcdefg");
QByteArray line = buffer->readLine();
write(line2);
write(buffer->readLine());
when i run the code ,the client return abcdefg+(the data which go back)
but if i delete raw 2 and 4,nothing return
wysota
3rd December 2008, 09:26
Are you sending a newline or otherwise flushing the socket?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.