Hi everyone.
I've recently gained interest in developing a game server and client from scratch. I don't plan anything big as of now, but I want the server to be scaeable to lots of clients. I have done some research and I see that ACE is a good networking library and that Mangos uses it. I've seen that there are a lot of ways of doing this but they have their strengths and weaknesses. Since mangos is written for an MMORPG and as such can handle lots of clients, I'm guessing the model which mangos uses to handle the connections and messages between the server and client is exactly what im looking for to learn. The thing is, there is too much code and the specific part I need to know is hidden there somewhere. So maybe if someone could explain, what model does mangos use? and how does it work?, i would appreciate it very much.
From what I've read, one can make a thread to listen the network and enqueue the messages so that other worker-threads read them when they have time to process them. I think this is called the half-synch/half-async model. I think this model uses a reactor in the listening thread and it blocks as soon as a message arrives, then enqueues the message and unblocks to start listening again. Another way of doing it was with a proactor instead, which is supposed to read and write asynchronously and as such, it won't block the thread so it can be implemented in the main thread, correct me if I'm wrong, I don't understand this method very well. Other models include: having a thread pool (which I don't understand either), having a listening thread for each connection (which scales poorly), or a single thread that iterates through all connections (which also scales poorly).
What I found in mangos code was it having a SOAP thread, a World thread, a database thread and a network thread if I'm correct. I also saw some reactors in the code and some enqueues and message queues, but i couldn't figure the model out entirely since lots of methods are implemented in other header or cpp files (and finding them can be complicated) and also because of the extensive use of defines which also is hard to find without an IDE. I didn't find a visual studio solution file (which is the IDE I'm used to) and I'm not sure what IDE are the files supposed to be compiled under windows.
I also read that for this type of applications (real-time with lots of clients, specially MMORPGs) UDP is better than TCP. I'm not sure if this has anything to do with the model I choose to implement, as in UDP can only be used with a proactor and TCP with a reactor or something like that. and if Mangos uses UDP or TCP.
I know that probably I should be looking for ACE tutorials, but i've done that already and there aren't as many, and the ones that do exist, are too generic. Since mangos is something very similar to what I want to do, and has already been developed, then I'm guessing having help from you guys would be very straight forward to my problem instead of generic tutorials which just confuse me even more.
So thanks in advance and sorry for my long post
SuperJugy.
PS. English is not my native language. Excuse me if my English is bad.