Zergi
11th January 2008, 17:15
Hi
I have very strange problem, QTcpSocket recive msg when i write something like that
tcpSocket->write("P\n"); but if i write something like that
tcpSocket->write("P"+t.toLatin1()); it dosent work
where t is QString
Sending function(server)
void server::Twyslijdane()
{
QString t;
QSettings settings("Users.ini",QSettings::IniFormat);
keys = settings.allKeys();
for (int i = 0; i < keys.size(); i = i+2) {
t = keys.at(i);
t.remove(QString("/Login"), Qt::CaseInsensitive);
t.remove(QString("/pass"), Qt::CaseInsensitive);
connection->write("D"+t.toLatin1());
}
}
reciving function
{
qint64 bytes = buffer->write(tcpSocket->readAll());
// go back as many bytes as we just wrote so that it can be read
buffer->seek(buffer->pos() - bytes);
// read only full lines, line by line
while (buffer->canReadLine())
{
line = buffer->readLine();
if(line[0] == 'D'){
line.remove(0,1);
dodajnicki(line);
}
}
}
When i m sending tcpSocket->write("P"+t.toLatin1()); program dosent use
this part of code
while (buffer->canReadLine())
{
line = buffer->readLine();
if(line[0] == 'D'){
line.remove(0,1);
dodajnicki(line);
}
Best Regards
I have very strange problem, QTcpSocket recive msg when i write something like that
tcpSocket->write("P\n"); but if i write something like that
tcpSocket->write("P"+t.toLatin1()); it dosent work
where t is QString
Sending function(server)
void server::Twyslijdane()
{
QString t;
QSettings settings("Users.ini",QSettings::IniFormat);
keys = settings.allKeys();
for (int i = 0; i < keys.size(); i = i+2) {
t = keys.at(i);
t.remove(QString("/Login"), Qt::CaseInsensitive);
t.remove(QString("/pass"), Qt::CaseInsensitive);
connection->write("D"+t.toLatin1());
}
}
reciving function
{
qint64 bytes = buffer->write(tcpSocket->readAll());
// go back as many bytes as we just wrote so that it can be read
buffer->seek(buffer->pos() - bytes);
// read only full lines, line by line
while (buffer->canReadLine())
{
line = buffer->readLine();
if(line[0] == 'D'){
line.remove(0,1);
dodajnicki(line);
}
}
}
When i m sending tcpSocket->write("P"+t.toLatin1()); program dosent use
this part of code
while (buffer->canReadLine())
{
line = buffer->readLine();
if(line[0] == 'D'){
line.remove(0,1);
dodajnicki(line);
}
Best Regards