Hi there, I’m a TOTAL Ruby newbie, but not new to programming.
I’m currently trying to program something I have no experience in ANY
language, much less Ruby, so it is getting a little bit out of hand,
also because I think I have some ideas of how I’d do it in C, or C#
maybe, but not so sure how to do it “the Ruby way”. Add to it that I’ve
never really dealt with these sorts of things before (servers and
threads), which is making things hard and has me here looking for
Basically, I want to write a little something (program? server?
daemon? service? what’s the difference?) that runs on a host (a public
one like bluehost, maybe) and accepts connections on two separate ports.
Now here’s where it gets tricky. This something is a kind of game
server, which basically can run several games concurrently. Each game
has a list of users that can play that particular instance of a game.
So for instance this program runs n games and game 1 has k users, game 2
has j users, and so on.
Now, this server has to accept a remote connection that gives it the
parameters of the game (on one port)–like the list of users allowed to
play that game— and accepts users connections to join game n (on
So I made a server with two threads, one to accept game configurations
and another to accept users. So far so good.
But now my question is: I want to have each game to run as a separate
thread, because each game is independent, right? So can a thread spawn
more threads? And doesn’t this get a bit unwieldly?
Is there a better way to set this up? How do I write a something that
runs n games simultaneously, and that accepts two types of connections,
and when a user “joins”, it somehow gets sent to the appropriate game
thread? Is there a way to pass messages between threads?