Server implementation...

Started by
14 comments, last by humanapp 16 years, 10 months ago
Hi cwilson. Guess I should have stated somewhere that this is not my first attempt at a chat server. But it is the first time to use threads, and after actually posting this, I have learned I am using threads when I don't need to (basically what you said). And yes, you assuming I was new at networking was correct, but I'm getting there.

Also, as of about 2 weeks ago, I have finished my simple chat server.
Includes but not limited to
* User name/password use that is saved and loaded.
* The user list can be edited at run time on the server
* Stat recording, but the stats are only bytes sent/received
* Up to 64 simultaneous users (not tested and limited only by Socket.Select in theory). Tested up to 5 users on same machine.
* A simple server side menu which allows seeing who is online, said stats, saving/loading user list, adding users, and broadcasting a message to all users online. On the other hand, this menu has been programmed in the MOST simplest way but it works.
* Handles a website testing to see if the server is online. The code is not something that you would probably recognize from the rest, but it would crash if I did not include it.

Now, on to the simple text MUD using the helped and insight gained here and in the programming of the previous stage of the server. Right now I am brainstorming on what I want to include, how I want to handle the database, and skimming through the book "MUD Game Programming" for some ideas. Plus I'm sure I will be asking a question or two here in the near future.

I would like to thank everyone for their opinions. If anyone would like to actually see my code, I am more than happy to share. Just message me at Imgelling@gmail.com.

Comments on the code...
The code is not documented very well, but I am willing to jot down a few comments in the code if requested. The code is also not very organized, but its very readable.

Thanks again.
my blog contains ramblings and what I am up to programming wise.
Advertisement
Well, it sounds like your application has already outgrown my earlier suggestions. I would only add that if you're now hitting a database (for registration and auth), the single-threaded implementation is sub-optimal, because the main loop will block on database calls. If you haven't already, you might look at implementing a worker thread pool to handle incoming requests.

Good luck. Have fun! :)

- Chris
Hi

You may wish to look at the 'Reactor' design pattern. Here's a link describing it, it's in Java but it should be easy to convert to C#:

http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf

Regards
elFarto
Imgelling I sent you a PM. I have completed a text based mud server. I am now working on a graphical mud server.
Imgelling, I sent you two PMs, if you do not receive them, then PM me your email, and I will respond to it.
Have you considered using the generic Queue class? It's FIFO. Here's some pseudo C#:

    Queue<NetMessage> pending = new Queue<NetMessage>();    // Gather pending messages inside lock    lock (queue) {        while (queue.Count > 0)            pending.Enqueue(queue.Dequeue());    }    // Dispatch pending messages outside lock    while (pending.Count > 0)        DispatchNetMessage(pending.Dequeue());

This topic is closed to new replies.

Advertisement