Results 1 to 20 of 20

Thread: gift to all networking noobs (as i am)...

  1. #1
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Cool gift to all networking noobs (as i am)...

    after finding lot of helpfull people here, i've decided to give something back (actually my own mutant-fork of closed source project), so i gave birth to

    http://code.google.com/p/elementalserver/

    and i hope this code will help many noobs to learn how does qt networking work.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Yes, of course it's threaded.... Geeeeez people, what's with you!?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    if you don't like threads, you can help write single-threaded version

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    I do like threads but not in this context. By giving such a code to people you are encouraging them to learn bad habits, this code is just wrong (both conceptually and technically), overbloated and unnecessary. If you want to give someone an example then make it simple.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    comment Code:
    1. this code is just wrong (both conceptually and technically), overbloated and unnecessary.
    To copy to clipboard, switch view to plain text mode 

    how can i know if something is wrong? only from people like you... but just to say 'it's wrong' it's not enough. What is wrong? How can it be improved? Do you have specific workaround for this and that?

    ...if NOT, it's just useless non-productive talk from your side.

    comment Code:
    1. By giving such a code to people you are encouraging them to learn bad habits
    To copy to clipboard, switch view to plain text mode 

    No! this is GOOGLE CODE! i dont encourage anyone to anything... you can take it or leave it.... or help improve it (best choice). I'm not saying "this is best software on planet", but saying "this is my piece of code, please, take a look and help improve.. and if you like it, share it."... coz this will be software for YOU people, not only for me....

    so please, dont forget you have to get hands dirty, before talking dirty... :P

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    comment Code:
    1. this code is just wrong (both conceptually and technically), overbloated and unnecessary.
    To copy to clipboard, switch view to plain text mode 

    how can i know if something is wrong?
    If you don't feel confident enough that your code is not wrong, don't post it as an "example" to others.

    only from people like you...
    You should know it based on your knowledge.

    Do you have specific workaround for this and that?
    It's not a matter of workarounds, it's a matter of concept.

    ...if NOT, it's just useless non-productive talk from your side.
    I already told you my doubts in another thread. And my (and not only mine) opinions about such network programming are scattered all over this forum. If that's not constructive enough for you, you'll have to wait about a month.

    comment Code:
    1. By giving such a code to people you are encouraging them to learn bad habits
    To copy to clipboard, switch view to plain text mode 

    No! this is GOOGLE CODE!
    No, this is QtCentre forum:
    and i hope this code will help many noobs to learn how does qt networking work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    i got your point, but as i said before..

    Qt Code:
    1. without your contribution , your comments are useless for me...
    To copy to clipboard, switch view to plain text mode 

    looks like you're coming from windows userbase and have no clue about contribution and sharing for FREE... do you?

    Qt Code:
    1. my (and not only mine) opinions about such network programming are scattered all over this forum
    To copy to clipboard, switch view to plain text mode 

    that's right, and that's why these opinions are useless, coz they are scattered all over and are just opinions without showing something 'that works' and is 'not wrong and bloated'. Or maybe it's problem with search engine, because if i put there 'single thread server', i'll find just questions without actuall answers. i thought this suppose to be forum TO HELP, not to flame, argue and blame someone 'your design is wrong'....

    if you have at least little will to help, download code... fix what you think can be fixed or make a 'new design' document (or whatever) , and mail me changes. dont forget it's your choice to IMPROVE IT, CONTINUE with your useless 'it's wrong'-attitude (coz saying 'it's wrong' is no help at all) or simply IGNORE it.... so make your choice!

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    looks like you're coming from windows userbase
    No, not really.

    and have no clue about contribution and sharing for FREE... do you?
    Forgive me, I will not answer this question. You should be able to find the answer to this one on your own.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: gift to all networking noobs (as i am)...

    i always like ppl who post their code on to the web. so gud job @daemonna. But the guy u r talking to is very experienced, so take his comments as positive.

  10. #10
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: gift to all networking noobs (as i am)...

    Daemonna, it's obscene to tell wysota with 19k messages and >2k thanks, that he doesn't know about contribution and sharing.

    Put that attitude back where it came from!

    Johannes

  11. #11
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default

    Forgive me, I will not answer this question.

    there's nothing to forgive wysota... it's your choice to contribute or not.. and i dont blame if you will not contribute. but i simply dont accept "this is wrong" statement without proper explanation and piece of code that WORKS good way. Open source community is live only thanks to people that come and give SOLUTION, not a people that come, complain and go...

    so dont take me wrong, i'm only gives here something that works (maybe wrong way, but it works) and can be changed by anyone to be better and to prosper to community.

    People! i'm not trying to put blame/flame/p*** on wysota head... NO! i know he's VERY experienced and probably knows more than anyone else, but saying only "THIS IS NOT GOOD" doesnt make him any better than any flamer. I ask for help, not personal help which gains me money, but help for OPEN SOURCE project to make it better (coz i'm not guru at all) and saying only "it's wrong" is like telling african children "go and find some food if you're hungry"... it's NO HELP AT ALL.
    Last edited by wysota; 17th September 2010 at 12:19.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    Forgive me, I will not answer this question.

    there's nothing to forgive wysota... it's your choice to contribute or not..
    Yes, it is my choice to contribute or not I'm happy I made the right choice.

    but i simply dont accept "this is wrong" statement without proper explanation
    I already gave you a proper explanation.

    and piece of code that WORKS good way.
    There is such a piece of code already in Qt docs.

    so dont take me wrong, i'm only gives here something that works (maybe wrong way, but it works) and can be changed by anyone to be better and to prosper to community.
    I'm sorry, but in my opinion each existing wrong solution puts people one more step away from finding the proper solution. I just don't share your point of view that a poor solution is better than no solution. Sooner or later this poor solution will explode in your face and you'll waste more time trying to patch it up than you'd spend thinking how to do it properly in the first place.

    saying only "THIS IS NOT GOOD" doesnt make him any better than any flamer.
    Suit yourself, I didn't want to make you feel bad but if you insist:
    - your application is leaking memory
    - your server is prone to DOS attacks
    - you are using shared memory for something that is completely irrelevant to the server and thus it makes no sense to put it in this 'example'
    - your shared memory thread has no exit condition (so your program is likely to never finish)
    - using a thread for your shared memory stuff is a pure waste of resources, the same could be achieved without using sleep, i.e using idle processing
    - you are using signals and slots with QThread in a wrong way
    - you are needlessly subclassing QThread
    - I have no idea why you operate on byte arrays in such a complicated way
    - you are putting literally everything into threads, even single method calls (even the non-blocking QTcpServer::listen()), God only knows why
    - you are using arbitrary values for.... yes, I have no idea why you are doing that...
    - you are using global/extern variables instead of encapsulating them properly (and you are using them across threads)
    - your archive has the size of almost 1.5MB, a bit much as for an "elementary example"
    - you should really read this: Keeping your GUI Responsive (just be careful, it's written by someone who doesn't contribute)
    - and this one too: You're doing it wrong

    If you want to share code -- good, I don't mind. But don't call it an "example". An example should be short, to the point and flawless.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. The following user says thank you to wysota for this useful post:

    daemonna (17th September 2010)

  14. #13
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    finally Guru said something wise....


    THANKS!

  15. #14
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    regarding your amends:

    now I see I need to seperate it, one for single/easy work, another for multi-threading... but to clear things up, primary job of server will be some usefull job, so dont take it only as 'example'...


    - your application is leaking memory
    probably yes, but i still study how to work with Valgrind to check that...

    - your server is prone to DOS attacks
    is truncating packets to small size (let's say 500bytes) enough? Is there any guru tutorial how to avoid DOS attack?

    - you are using shared memory for something that is completely irrelevant to the server and thus it makes no sense to put it in this 'example'
    coz it also suppose to be example of sharedmemory among threads, but yes, i'will probably kick that code out...

    - your shared memory thread has no exit condition (so your program is likely to never finish)
    - using a thread for your shared memory stuff is a pure waste of resources, the same could be achieved without using sleep, i.e using idle processing
    - you are using signals and slots with QThread in a wrong way
    - you are needlessly subclassing QThread

    WE ALL DOING IT WRONG THANKS TO DOCS THAT HASNT BEEN UPDATED... just see comments on http://labs.qt.nokia.com/2010/06/17/...comment-page-1 . But I promise I will try to learn it doing it right, thanks to your link.

    and in "threading-without-the-headache" is nice comment

    Nice example. However, you do have a hiden lock — the one that Qt uses for signalling across threads, right?
    Also, this only works with 1-1 producer/consumer, not for MxN setups.

    so I wasnt doing it that much wrong, because original project is multi-user multi-game server... not single game session. that's why i did it such complicated way...

  16. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    now I see I need to seperate it, one for single/easy work, another for multi-threading... but to clear things up, primary job of server will be some usefull job, so dont take it only as 'example'...
    A good example is something to build upon.

    - your application is leaking memory
    probably yes, but i still study how to work with Valgrind to check that...
    You don't need valgrind here, just look at your code.

    - your server is prone to DOS attacks
    is truncating packets to small size (let's say 500bytes) enough?
    This is not a problem.

    WE ALL DOING IT WRONG THANKS TO DOCS THAT HASNT BEEN UPDATED... just see comments on http://labs.qt.nokia.com/2010/06/17/...comment-page-1 .
    You can't blame pure virtuality of QThread::run() for all your thread problems. The nature of using QThread never changed and all that was explained in the docs, it was still suggested to call QThread::exec() from within QThread::run and work on objects.

    so I wasnt doing it that much wrong, because original project is multi-user multi-game server... not single game session. that's why i did it such complicated way...
    I think you misunderstood the comment. It doesn't say that you can't have multiple clients without threads.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #16
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    regarding threads i have to admit i didnt understand them well till your pointing tutorial... another thing to learn

    regarding memory leak just look at your code is not enough, i got more programming/admin/study stuff in my head, so i dont think pure look will suffice... that's why Valgrind.

    regarding DOS attack i can quickly imagine only 2 DOS attacks.. one is overflow socket with too many packets (so responce delay should help.. aka sleep() ), second is that packets are too big (that's why to truncate big data)...

    regarding last point, i dont talk about multiple clients here... i talk about multiple games in 1 process and each game can have multiple players... this is something completely different and only substitute i see here is some kind of clustering.

  18. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    regarding memory leak just look at your code is not enough, i got more programming/admin/study stuff in my head, so i dont think pure look will suffice... that's why Valgrind.
    You are not deleting any objects you allocate.

    regarding DOS attack i can quickly imagine only 2 DOS attacks.. one is overflow socket with too many packets (so responce delay should help.. aka sleep() ), second is that packets are too big (that's why to truncate big data)...
    Third is too many clients connecting at the same time, fourth is existing (broken or malicious) clients staying connected forever reaching the limit of clients allowed.

    regarding last point, i dont talk about multiple clients here... i talk about multiple games in 1 process and each game can have multiple players... this is something completely different and only substitute i see here is some kind of clustering.
    Honestly I don't see how the comment from labs is related to what you say and how it is related to what I said.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #18
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by wysota View Post
    You are not deleting any objects you allocate.

    Third is too many clients connecting at the same time, fourth is existing (broken or malicious) clients staying connected forever reaching the limit of clients allowed.
    i'm still little bit confused about constructor/destructor working in QT4. Is it only children of QObject that will be automatically destructed??? so anything else i have to write destructors myself??

    regarding DOS attack:

    if i'm not wrong, with QTcpServer::setMaxPendingConnections is easy to set max clients and to check if client is idle is also easy with QTime::elapsed ()

  20. #19
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    62
    Thanked 260 Times in 246 Posts

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    i'm still little bit confused about constructor/destructor working in QT4. Is it only children of QObject that will be automatically destructed??? so anything else i have to write destructors myself??
    Only classes that are derived from QObject can be part of a parent-child relationship, and the parent is responsable to delete his own childrens, when the parent goes out of scope (if the parent is created on the stack) or when the parent gets deleted (if the parent was created on the heap and does not have another parent)
    Here is a simple Hello world example:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char** argv) {
    4.  
    5. QApplication app(argc, argv);
    6.  
    7. QWidget *w = new QWidget(0);
    8. QLabel *l = new QLabel("Hello Qt World!", w);
    9.  
    10. w->show();
    11.  
    12. int ret_val = app.exec();
    13.  
    14. delete w;
    15.  
    16. //we must delete 'w' because: 1) we create it on the heap 2) it doesn't have a parent
    17.  
    18. //we don't delete 'l', because 'w' it's his parent and will take care of deleting 'l' for us
    19. //if you try to delete 'l' you might get some "segmentation fault" errors
    20.  
    21. return ret_val;
    22. }
    To copy to clipboard, switch view to plain text mode 

  21. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gift to all networking noobs (as i am)...

    Quote Originally Posted by daemonna View Post
    if i'm not wrong, with QTcpServer::setMaxPendingConnections is easy to set max clients
    "max pending connections" has nothing to do with the maximum number of clients. It's the size of the backlog for ::listen().

    and to check if client is idle is also easy with QTime::elapsed ()
    I surely wouldn't do that with QTime::elapsed(). You are still thinking in a synchronous manner.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QT non-gui networking
    By MAbeeTT in forum Newbie
    Replies: 1
    Last Post: 21st August 2009, 19:47
  2. Qt4 Windows Networking
    By bothapn in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 17:31
  3. Qt-3 and networking
    By a550ee in forum Qt Programming
    Replies: 3
    Last Post: 3rd October 2006, 11:15
  4. Networking Help please
    By munna in forum Newbie
    Replies: 1
    Last Post: 17th September 2006, 09:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.