I want to make a server that can handle many
connections at once, problem is that I can accept
many connections, but how do you handle many
requests that may be different making the server
do more then one task at the same time? and keep
track of who is who on what port ect.? should I make
a thread? and will the treads be in there own memory
so that the varables will not get over written?

In otherwords, how can I make a thread that will be
alone untill it is done?

Posted on 2001-07-25 02:47:09 by Zcoder
I suggest taking a peek at "crinchy server" (sp?) at iczelions site... it handles multiple connections if i'm not misstaken...
Posted on 2001-07-25 03:07:31 by NervGaz
use asynchronous sockets, as shown in iczelion examples.

Rules of thumbs:
1) for high volume server use overlapped I/O (don't think it's your case)
2) for 100-1000 connections use asynchronous sockets (easy, clean and efficient ... if coded correctly :)

I would recommed staying away from multi-thread, it's easy to code a server this way, but it's not ... how should I put it ... very efficient and scalable

for more info check
Posted on 2001-07-25 06:17:33 by random
Personally I prefer multi-threading but just as random says, async is better for a high load server if you are using windows. If on another OS then you could have done multi-threading and got away with it. But not using windows, it just sucks too much.

But if your server is a low bandwidth server that most likely never get more than say 20 users at any given time then you can use threads. I don't like windows way of doing async sockets using a msg handler for a window to process the events and that's my reason for prefering threads, im the kind of person that think servers should have no GUI related code in them ;)

Im personally thinking of writing a HTTP/1.1 server but can't decide if I should go for threads or not. And im thinking about a real http server supporting directory based permissions (user,group,ip based), multiple domains, cgi support, file caching (hd stress releaving), plugins (for adding things like bandwidth meters and logging), etc... oh and i won't have a GUI and will be configured using textfiles (not .ini tought because it is way to limited)

But i have to read up on async and non-blocking sockets :)
Posted on 2001-07-25 12:31:54 by Zynaps
I've done much HTTP stuff for my next version of HTTPFT, and I'm using a combination of both..
I use one asynchronous listen sockets, where the main window processes incomming connections. Then for each connection, it creates a new thread which has it's own message queue. With this message queue I mean one I designed myself, it has nothing to do with windows so no windows are created for the conections. All messages are processed in the main window. When a specific thread needs to be notified data has arrived for it, it sends a thread message to that thread. It's a pretty stable and fast server this way.

Posted on 2001-07-25 12:40:41 by Thomas
Another option is CreateThread, I use it to do this for me, works great :)
Posted on 2001-07-27 09:47:01 by clip