Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Server can only receive one message at a time?  (Read 8770 times)

0 Members and 1 Guest are viewing this topic.

Grimlen

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Server can only receive one message at a time?
« Reply #15 on: September 20, 2012, 06:56:13 pm »
There doesn't appear to be any tutorials on version 2.0 for networking (unless I saw wrong).
I've got a roster of people all ready setup for 1.6 and we'd rather not switch as we've been working
hard with 1.6. Anyways....
To be honest I'd rather want to know what's wrong with my code now.
I've gone over the tutorial on the TCP section and I'm absolutely dumbfounded why I can only
get just one message per connection.....

Could you possibly test it to determine what's wrong? I've been stuck on this for a while.
« Last Edit: September 20, 2012, 07:16:14 pm by Grimlen »

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Server can only receive one message at a time?
« Reply #16 on: September 20, 2012, 07:21:54 pm »
I would recommend using threads, as non-blocking sockets are a bit more complicated than they appear.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Server can only receive one message at a time?
« Reply #17 on: September 20, 2012, 08:37:38 pm »
Quote
Could you possibly test it to determine what's wrong? I've been stuck on this for a while.
My free time is really reduced to minimum, so I'm a little lazy and never test 1.6 code. Also because I have stopped maintaining SFML 1.6 3 years ago and a lot of bugs have been fixed in SFML 2. Sorry.

Although the tutorials are not written yet, networking hasn't changed much and you should be able to convert your code easily with the 1.6 tutorials and the 2.0 API documentation (which is much more detailed and has useful examples).

Quote
I would recommend using threads, as non-blocking sockets are a bit more complicated than they appear.
Not really. At least not for this use case.
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Server can only receive one message at a time?
« Reply #18 on: September 24, 2012, 12:21:34 am »
Well depending on the situation, the packet-end byte in a non-blocking socket system isn't recognized by the client or server so certain protocols will appear to cluster packets together.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Server can only receive one message at a time?
« Reply #19 on: October 28, 2012, 07:08:32 pm »
another thing you could do is multithreading your server so it can have more than one client at a time.  It's good for when you want any number of clients on a given server but it helps if the code is as reuseable as you can get it.  As soon as I get done fighting with an Object/Memory manager I'll see what dig up on issues like this.
I have many ideas but need the help of others to find way to make use of them.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Server can only receive one message at a time?
« Reply #20 on: October 29, 2012, 08:49:59 am »
another thing you could do is multithreading your server so it can have more than one client at a time.  It's good for when you want any number of clients on a given server but it helps if the code is as reuseable as you can get it.  As soon as I get done fighting with an Object/Memory manager I'll see what dig up on issues like this.

Multithreading with sockets is generally a bad idea, usually if you do it wrong. A process can only have ~2000 threads (a lot of the time much less, depending on the system and whatnot), so having a big server can screw things up. Plus processor affinity can play an issue if a client is sending malicious content; it can potentially slow down the main thread, or another crucial thread.

If you want to have something similar to multithreading, it's best practice to use non-blocking sockets.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

 

anything