Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > Designs decisio...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 4052 of 4146
Post > Topic >>

Designs decisions: Programming model for a socket-based networking framework...

by "Chris M. Thomasson" <no@[EMAIL PROTECTED] > Sep 24, 2008 at 08:59 PM

What model do you like better: Asynchronous state-machine based on 
callbacks, or single-threaded model backed by user-space threads? Its a 
difference between something like this:


class IO_Callbacks {
  virtual void On_Send(...) = 0;
  virtual void On_Receive(...) = 0;
  // [...];
};


class My_Connection : public IO_Callbacks {
  void On_Send(...) {
    // [handle the event];
  }

  void On_Recv(...) {
    // [handle the event];
  }
};





or:



void My_Connection(...) {
  for (;;) {
    if (! IO_Receive(...)) {
      break;
    }

    if (! IO_Send(...)) {
      break;
    }
  }
}



I have to admit that the latter is easier to reason about. I can't make up

my mind! Dammit!

;^(...
 




 10 Posts in Topic:
Designs decisions: Programming model for a socket-based networki
"Chris M. Thomasson&  2008-09-24 20:59:06 
Re: Designs decisions: Programming model for a socket-based
Szabolcs Ferenczi <sza  2008-09-25 03:02:07 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-25 03:31:59 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-25 03:33:21 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-25 03:37:05 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-25 03:27:36 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-25 03:28:56 
Re: Designs decisions: Programming model for a socket-based
David Schwartz <davids  2008-09-25 15:17:25 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-26 15:23:41 
Re: Designs decisions: Programming model for a socket-based netw
"Chris M. Thomasson&  2008-09-26 16:41:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 9:03:11 CST 2008.