QT/C++ Server Login System

Questions about programming languages and debugging
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

QT/C++ Server Login System

Post by maboroshi »

Hey everyone as part of a current project I am building a Server Login System this is far from complete.

I would like suggestions possibly with code either based on my code or a rewrite of my code on how to handle the login, cause criminey I can't figure it out.

Gogeta gave me pseudo code to follow from, but hell if I could understand all of what it said.

Anyone with advice please post (Cats, Anyone Else)

I will post the relevant parts of my code but it is far from being efficient

Then client sends this

Code: Select all

QByteArray Buffer;
Buffer.append("0" + username->text() + "@" + password->text());
socket->write(Buffer);
*cheers and thanks for any help :-)

Mabo

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Re: ZOMG QT/C++ Server Login System

Post by maboroshi »

NOT SOLVED

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: SOLVED - ZOMG QT/C++ Server Login System

Post by ayu »

ah, gj! :D =D>
"The best place to hide a tree, is in a forest"

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Re: SOLVED - ZOMG QT/C++ Server Login System

Post by maboroshi »

Actually that code I posted second didn't work quite as expected

The first code was more accurate but I learned some things

*cheers

Mabo

User avatar
Lundis
Distorter of Reality
Distorter of Reality
Posts: 543
Joined: 22 Aug 2008, 16:00
15
Location: Deadlock of Awesome
Contact:

Re: SOLVED - ZOMG QT/C++ Server Login System

Post by Lundis »

This is a completely random remark on your code. :mrgreen:
QByteArray Server::getPart(const QByteArray message, int part, bool toEnd)
You're using const there to hopefully let the compiler optimize stuff, but unfortunately using const like that should only have compile-time benefits (you cant accidentally modify it). To save memory and time, you should use a const reference instead:
QByteArray Server::getPart(const QByteArray& message, int part, bool toEnd)
This wont copy the QByteArray, and it doesn't change the syntax anywhere else at all. It's a very common practice in C++, for avoiding the copying of large data structures. :D

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Re: SOLVED - ZOMG QT/C++ Server Login System

Post by Gogeta70 »

Lundis wrote:This is a completely random remark on your code. :mrgreen:
QByteArray Server::getPart(const QByteArray message, int part, bool toEnd)
You're using const there to hopefully let the compiler optimize stuff, but unfortunately using const like that should only have compile-time benefits (you cant accidentally modify it). To save memory and time, you should use a const reference instead:
QByteArray Server::getPart(const QByteArray& message, int part, bool toEnd)
This wont copy the QByteArray, and it doesn't change the syntax anywhere else at all. It's a very common practice in C++, for avoiding the copying of large data structures. :D
This is a good point. In fact, it's something i often forget to do in my code as well. I generally don't optimize my existing code unless it's showing signs that it needs it though.
¯\_(ツ)_/¯ It works on my machine...

Post Reply