Jump to content

Making a HTTP Request in C++

- - - - -

  • Please log in to reply
11 replies to this topic

#1
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
  • Location:Australia
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly
Hello All,

Is it possible to make some form of HTTP request in C++? Also, is there a way to control ports in C++?

I heard stuff about it and wondered if it was possible in C++.

Thanks.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You need to make a network connection, and send/receive appropriate HTTP compliant messages over it. Most web browsers are coded in C or C++.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Warrior

Warrior

    Programmer

  • Members
  • PipPipPipPip
  • 130 posts
These things are platform dependent and you will have to use the corresponding API of the OS you are using.
Windows provide Wininet which makes it easier to do http://msdn.microsof...3%28VS.85).aspx
Also sockets socket Function (Windows)

Linux is great for networking Linux Howtos: C/C++ -> Sockets Tutorial

Warrior

#4
TeenChristian

TeenChristian

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 639 posts
What would the ability to control ports do? :o
sounds interesting, but I have no clue what the benefit is

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
There is also a boost library that can help you make cross-platform code. Of course, it will use the underlying platform to make the connection. Boost.Asio
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
  • Location:Australia
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly
Well, sounds too complicated to be answered in a thread, so what concepts would I need to learn?

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Mostly, you just need to know the format of an HTTP request, which is pretty simple.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
  • Location:Australia
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly
Yeah that's simple, but how do I implement that into C++ code? What syntax? (After I had the library of course).

#9
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You just open a connection on port 80 (I haven't used the asio library, so would need to look up the syntax myself), then just send a message that is compliant with the standard HTTP protocol.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#10
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
  • Location:Australia
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly
That's why I wanted to know how to open ports in C++.

#11
Chrisaster

Chrisaster

    Newbie

  • Members
  • Pip
  • 1 posts

Hunter100 said:

That's why I wanted to know how to open ports in C++.

It depends on your operating system. If you're using Windows then I would advise you learn about WinSock here.

#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Tutorial
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users