Socket programming using kdevelop

  • helmut
  • Newbie
  • Newbie
  • helmut
  • Posts: 5

Post 3+ Months Ago

i managed to create a server that will create a new socket for every client that connects to it.

But then i'm having problem as in, if theres 2 client connected, the following code will only listen and wait for 2nd client's data, before it moved on to process client1's data. What method/codes should i use so that it can simultaneously receive n decode data from both or more clients at the same time?

say i = 1, 2 clients connected.

Code: [ Select ]
while(i >= 0)
{
p[i] >> p[i].data;
cout << p[i].data << " received from player client " << p[i].id;
i--;
}
  1. while(i >= 0)
  2. {
  3. p[i] >> p[i].data;
  4. cout << p[i].data << " received from player client " << p[i].id;
  5. i--;
  6. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9087
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Is your server forking or creating new threads for each person that connects to a socket? Forking or creating new threads should allow you to create many ongoing processes that will not have to wait on each other.
  • helmut
  • Newbie
  • Newbie
  • helmut
  • Posts: 5

Post 3+ Months Ago

threads? hmmnn didnt use that in my program. I should try it out later tonight =)

Thx for your reply

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: hFJyCxL1 and 131 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.