in reply to Single non-server script maintaining multiple client connections

There are many ways to do this. Which is most appropriate really depends upon the nature of the logic involved.

For example, if the conversations with each of the servers is complex and mostly independant of the other, with only the occasional need to share state, then putting each in it's own thread and sharing state through a queue or shared variables may be the simplest approach.

If however, the conversations are highly interdependant with each driving the other, then the select approach makes more sense.

Each approach has both advantages and caveats. The right choice depends entirely upon the nature of the application.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re: Single non-server script maintaining multiple client connections