Simple webserver for c++ [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My c++ server-app needs to have a port 80 open to output some json
(for other web-apps to see the status)
I saw a few web-server that i can spwan from a c++ class, but they seem rather complicated. I don't need any request/response, just a string that i time by time update and that is shown on port 80 then.
My server-app is running in a loop, so i guess this should be a thread that gets the string update every here and then. Please point me in the right direction is i am totally wrong in my planning/thinking.

The simplest solution would probably be to use a webserver to serve a static file and having your application to update the content when needed.
Just pay attention on the configuration of the server to inform the clients that the content should not be cached.
Another somewhat important part is to create a new file and move it to the destination (published) location once the file is complete (to avoid clients to download a partial file that could be invalid).

You could use some HTTP server library like libonion (or perhaps Wt or libmicrohttpd) within your C++ application.
Notice that libonion usually runs the web service in some other thread, so you need to take care of synchronization (e.g. using mutexes), and is also able to serve static content and static files.

Related

How does data get stored in online exams or tests in real time when the connection's OFFLINE? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'd like to know how or where data gets stored in an online TIMED exam or test when the network connection becomes offline! I've seen scenarios where the network connection suddenly drops down and when the user logs into his account again, finds that the he can resume his test from the point the connection went offline! So, where does the data of his answers to his previous questions actually get stored? Is it in the client or server side? Do the test providers use any offline storage for these?
I was just curious about this (and kinda new to this) and couldn't find any accurate explanations for this in any search engine. A li'l guidance would be much helpful! [This could really be some kinda basic question I'm sorry for my ignorance- but I really don't know]
Without knowing the particular exam/system in question, the answer will be a bit generalized. Here goes:
The client side (code running in the browser most likely) must be saving the answers directly to the server as they come in.
The client side can also be linked to the server where the test results are stored. This can be done via a live link such as websockets. Once the server detects that the client is 'down' (for whatever reason) the server may or may not stop the timing of the test. It all depends on the specifics of the particular test. Care to share which?

Window - Lock Program Background [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to lock a program in background by adding a service to background. The user needs to input password to use the program.
sc create newservice binpath = "C:\Users\User\Test.exe"
The problem is, I am not sure that How can I write the program.
First, what programming language can I use? Cmd, C++ or others?
Second, how can I write this exe?
I have heard this from my friend, but I am not sure how to write this.
Any help will be appreciated.
First note, background process not must be service.
Second note, if you wish wrote service, take in account Vista and above session isolation. Also service may run in another account.
Third note. How do you 'trap' browser? Code injection? Finding by process name/ window name? .... Many counterattacks exists, so this is not trivial thing.
Forth note, What if stop service or close/kill your process?
Fifth note, how do you wish store passwords? If as plain text, every skilled person obstruct your app. If encrypted, more code you must wrote...
Sixth note, nobody on SO.com wrote code for wish without you.

How can I "do stuff" on a webpage through C++(or suggest another language) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What I exactly want to do is this:
I want my program to take this link
http://answers.yahoo.com/dir/index;_ylt=Aj_zP9qxkgoIzbqd5GR_zkH05nNG;_ylv=3?sid=396546041
and retrieve a list of all the questions in a page or any selected page. That part is easy through simply going through the page, but I want to be able to "do" things such as typing an answer in the console or window and post it in the question in that forum. Or be able to upvote/downvote and do most of the operations that require a button click. Save questions for later view and other things like that.
My approach for retrieving info is using C++ to parse the info from the page by going through it line by line. But I have absolutely no clue how to send information such as button pressing and other stuff. I even don't know how to search for it because I'm not sure what it's called.
Use sockets api (windows sockets or posix on linux);
Connect on 80 (or any http) port to your server;
Send a http-header and get/post parameters (should be urlencoded);
Receive response.
Keywords: http-protocol, berkeley sockets, c++, good luck!

Saving data into file at free host [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have created an app (some kind of "client" app) that will have a "bug report" feature. The feature consists with pure text area from which the text should be sent and saved to a text file on the free host. Is it possible? If so, which c++ library could give me such ability?
EDIT:
In my intentions it had to be a simple application that a user has on his own computer. After finding some bug in my app there should be the "bug report" feature that will allow him to send the data (pure text) to some place that only I could reach. I was just thinking about free hosting (because it's... free), and save the data into a text file there. I'm sorry if my question wasn't appropriate.
If your free hosting permits it (and you should check that) you might code a CGI program, or a fastCGI application. There are several C++ libraries which might help, like libcgicc etc.
If you can afford a web server, there exist C++ libraries providing HTTP service, in particular Wt or (in C) Onion etc.
You could also consider other technologies, like OpaLang or Ocsigen (but I would not recommend PHP, even if it is a lot used).
MAybe your hosting enable ssh so you could use scp ....
And if your application is free software (e.g. GPL licensed), several free software hosting (freecode, sourceforge, github, gitorious ...) may offer also a bug database facility.

How to write a good program for blocking unwanted / harmful websites [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I intend to write a simple application that will block network traffic (HTTP and HTTPS) with unwanted / malicious web sites.
Assumptions:
At the beginning the logic will be simple. After entering in the browser the address from the "black list" my logic should take control under communication and send defined by me site contents
Later I want to add some logic that will search web body looking for unwanted / harmful words
The program will be written in C++
I do not want to use existing libraries (open source etc.) only write all from scratch. J just want to learn windows network mechanism and layers
Unfortunately, I am a layman when it comes to play with the network layer in Windows.
Where do I start?
Where and how should I inject my filtering logic?
You should look into Windows Filtering Platform. This API gives you access to the network stack at a very low level.
You have at least 2 options:
Build your own proxy that filters traffic and replace unwanted content and setup this proxy in browser settings.
Create NDIS filter driver. You can start reading about NDIS here. You can also find sample driver in WDK.
I would prefer the first option.
I a working on something similar in my spare time(as if I had any).
It's not very easy.
It depends a lot on the OS version.
There's LSP(Layered Service Provider) but as I understand it it doesn't work on Win 7 or later. There is an implementation of something similar to what you are trying to achieve here.
For Win 7 and above there is the filter driver alternative but I tested it and if the site is using SSL you won't see anything. You have to somehow handle this either within the driver itself or redirect the traffic to a man-in-the-middle proxy. I didn't get that far yet.
Anyway this is M$'s official sample. And you might also be interested in this.