Hi
I have very strange problem, QTcpSocket recive msg when i write something like that
tcpSocket->write("P\n");
tcpSocket->write("P\n");
To copy to clipboard, switch view to plain text mode
but if i write something like that
tcpSocket->write("P"+t.toLatin1());
tcpSocket->write("P"+t.toLatin1());
To copy to clipboard, switch view to plain text mode
it dosent work
where t is QString
Sending function(server)
void server::Twyslijdane()
{
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());
}
}
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());
}
}
To copy to clipboard, switch view to plain text mode
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);
}
}
}
{
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);
}
}
}
To copy to clipboard, switch view to plain text mode
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);
}
while (buffer->canReadLine())
{
line = buffer->readLine();
if(line[0] == 'D'){
line.remove(0,1);
dodajnicki(line);
}
To copy to clipboard, switch view to plain text mode
Best Regards
Bookmarks