2

Im new in C++.

I need to listen HTTP requests.

Please advice me some good tutorials or examples

Thanks

update:

Platform: Windows Language: C++

I will explain more clearly what i need

when user clicks row on this page: http://ucp-anticheat.org/monitor.html applications is automatically starts on client machine.

I want to make same thing.

I think on client side is service which listens http requests and if url starts with steam:// service automatically runs application...

Do i need to listen http requests?

What is best solution for my problem?

Irakli Lekishvili
  • 33,492
  • 33
  • 111
  • 169
  • 3
    Use [The Source](http://httpd.apache.org/download.cgi#apache24), Luke! – Jerry Coffin Jun 29 '12 at 17:38
  • Q: Does it have to be C++? What about C? Or Java, Python, C#, etc etc? Q: What platform? windows? Linux? Q: What's the application/what are the requirements for this "embedded web server"? Q: Have you looked at the [Boost Libraries](http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/examples.html)? – paulsm4 Jun 29 '12 at 17:40
  • To be fair, working with the boost libraries is not a simple task when you are beginning with C++. Correctly handling HTTP-Requests is not a simple task either. – niko Jun 29 '12 at 17:42
  • Using the Boost libraries is somewhat akin to being in heaven... – Lusitanian Jun 29 '12 at 17:52

3 Answers3

3

You can listen to http requests through a web server like mongoose , which can be easily used in C++ http://code.google.com/p/mongoose/ , and here is a good example of using mongoose web server http://code.google.com/p/mongoose/source/browse/examples/hello.c

I m not sure what you mean 'client side', if you are meaning Browser as your client, you can't control nothing outside your browser. If you want to control a machine, you need your client machine to run your exe, that has the code to act based on your server instructions.

Manikandaraj Srinivasan
  • 3,557
  • 5
  • 35
  • 62
2

You should create a simple server program, create a SOCKET listening on default http, https etc, ports. Usually we do it inside a loop (at each one you make a read).

Now... would be easer if you specified if you are on Unix like OS or Windows, but from now on you can google it. Like sys/socket.h or try "man 7 socket" on almost all linux (at least the ones I know).

If you want to sniff something you can google some specific apps around web.

Rodrigo Gurgel
  • 1,696
  • 2
  • 15
  • 32
1

If i get your question right, you want to be able to launch an application when someone clicks a link with a custom protocol, like steam:// or telnet://. You are looking for an Protocol Handler.

A simple way to register such an application is using the ftype program, as described here.

Community
  • 1
  • 1
niko
  • 1,816
  • 13
  • 13
  • I should up-vote your answer, but it little different from the question title, I was looking for similar solution, I thought using http link & http server to direct link for web page (e.g YouTube video download), your suggesting were more suitable for me, to create connection between web-browser and external command(I need it for Linux BTW) – Salem Oct 24 '21 at 12:01