Multithreaded Webserver in C++ [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to do a multithreaded Webserver with scheduling and synchronization in C++.This is an assignment problem and I am not asking the code.I have done till the socket connection in server but I dont know how to proceed.I just want some hints or flow for the program.
Here are the few questions I have
1) I have done till socket accept().So when new connection comes I have to fork() and then close the connections of the child process.Is that right?
2) How must I make sure the program is synchronized wth so many threads running?
3) I must have 2 thread pools.1 pool of workers and in the other 2,1 each for acepting connection and inserting the request to ready queue.How can this be done?
I am not asking the code.I just need some hints and guidance.Thanks a lot.

Very interesting course work , if you get you head around this one a lot of concepts will become clear namely concurrency and one of its major use cases I.e. networking!
I used the following article myself to get a quick summary of my options in network concurrency in Linux
http://m.linuxjournal.com/content/three-ways-web-server-concurrency?page=0,0
This article give very high level intros to concepts tha thou will need like copy on write for forked processes and as a result separate address spaces negating sync in certain cases, once you have read this you will have more specific question that you can as once you start getting your hands dirty starting with the code in this article.

Related

AdHoc network Library Linux [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to set up an AdHoc network in linux (Debain specifically) in a C/C++ program. It needs to be able to search for existing networks, or at least confirm that a network exists with a given SSID, connect to it, and be able to determine the number of jumps it takes to get to any given node.
I do have enough programming experience to write my own, but it would be a whole lot of work and this seems like a common enough task that there's bound to be one in existence already. I suppose it doesn't have to be c/c++ (I could run the program externally or create some sort of wrapper), but it would be very nice if it were all "one" language.
Thanks in advance!
You could download an open source program that does the scanning + connection, like
iwScanner
or wicd is probably more appropriate
and modify it to fit your needs,
or connect via existing command line tools, in a script
Sample steps in this page
Regarding counting the number of hops, you can use the traceroute utility, in a script,
traceroute man page

How does one make something real time? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
This might be a really stupid question, but I can't find any info on this, and I can't find out what to search for.
How do you make something real time? For example, say we have a game, how does it run continuously without us calling a tick() method at different parts of the program?
If you are developing the program to run at a time in particular the best way I know of is to develop it to run at a particular loop rate using timed delays.
IE:
while(forever) {
do something
test how long it took
take up the remainder amount of time for the loop to run at a rate (ie 100Hz)
}
If you are desperate for real time applications you can develop and use QNX:
http://www.qnx.com/
But this certainly wouldn't be a good environment for programming games.

Sequential and running in one thread time difference c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here is my source code for testing multithread performance in C++. Please tell me why is time about 5x smaller for ONE thread running(WaitForMultipleObject()) then first sequential performance. I expect almost same result for sequential performance and running with only one thread. Thanks
http://pastebin.com/EeJ5qW03
OS will decide when will your thread start running and it will also decide if there's a need for dispatching, perhaps. Add to that, it also has to create a separate stack for your thread, perhaps.
Read about the overhead on thread creation. All in all, the overhead is system specific.

Run "While loop" in background [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have a Credential Provider dll application in C++. Inside this dll i create a process that will write some data in a file. I need somehow to read that data from file till the value is > -1. I can not use a while loop because my dll will stop loading till the while loop will end. Can i use a separate thread to do this and to get a notification to run a function from my dll when the while loop end? How can i do this? Is there a simple way to do this?
Thank you.
The only really practical way to achieve concurrency is using threads. Take a look at boost threads.
If your compiler implements C++0x thread, then you can make use of it.
Read this extensive tutorial on C++0x multi-threading : Multithreading in C++0x part 1: Starting Threads

Any way to reduce load on server [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am about to make an online game that will be played by about 1500 people at the same time. It will be a simple AJAX based quiz for a college competition. But the last time I made such a quiz, due to heavy traffic, the server kept crashing. We had to restart the server several times during the game. Still, access to the site was very slow. I have seen other college websites and their games don't seem to have such problems. Can anyone tell what might be our mistake? Since I am a student at college (not even of computer science), I am not very much aware of server administration.
Simply put, you are overloading your server with hits so you may want to look at the server stats to see where the bottleneck was/is. Only then can you decide if going with a larger server is more beneficial, or splitting out the application into another tier ...web and application.
this will spread load more evenly and reduce your bottlenecks.
Called smart programming.
Get a profiler.
Find out where the time in your code is spent.
Fix it.
That is all you can do. THis is not server administration, thisis bad programming bogging down the server, and you ahve to make an analysis and fix it. 1500 people on a quiz is something a mobile phone should be able to handle, so whatever server you ahve is big enough.