all 9 comments

[–]IkeConn 2 insightful - 2 fun2 insightful - 1 fun3 insightful - 2 fun -  (1 child)

Three letter agencies will be watching your ass day and night.

[–]humancorpse[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

[–]humancorpse[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (4 children)

most web servers, upon receiving an incoming socket connection and after having accepted it, most programs will perform a "fork" which will create a separate thread that will process that page and then the primary program will resume waiting for and accepting new http connection requests..

instead of my program "forking" to create threads to receive an incoming http request headers and then responding by sending back a response that consists of html and javascript, nope, i dont wanna use threads.. i will have my software operate as a "state machine", whereby i will cycle thru all actively being processed pages AND wait for and accept new connections.

obviously my program will be operating in a "non-blocking" mode.

pseudo code:

for(socket=0;socket<MAXSOCKETS;socket++)
{
wait_for_incoming_request();

read_incoming_header();

generate_dynamic_page();
}//for loop

[–]fschmidt 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

This makes no sense. Threads are better.

[–]humancorpse[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

i understand that you like the threads method of doing things...

but it is just my preference to use what i call a "state machine", which means that i have one program loop that does a little of this and then a little of that and then repeat..

i dont know how old you are, but i am 58 and i have been coding since 1983 and i am simply set in my ways.

i like the state machine method.

btw, i spent about six months experimenting with java and it is a very nice language but i dont think that it produces as fast and tight of code as does C.

:)

[–]thefirststone 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

That's just called asyncronous event handling. It can scale very well. Not all servers are multithreaded, especially on platforms or runtimes where threads have large overhead.

[–]humancorpse[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

yeah, i like the state machine..

[–]fschmidt 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

I already did this in my goodjava.webserver.

[–]humancorpse[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

should you ever like to look into writing sockets code in C, you should check out beej's sockets stuff..

https://beej.us/guide/bgnet/html/

his guide is primarily focused on writing sockets code on a linux box.