CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    Join Date
    Sep 2014
    Posts
    10

    How do I receive POST data in a C++ program

    I need to write an interface program in C++ to receive occasional data being sent to me from a different company from across the internet. The company says they will send the data using POST. They have given me a document that lists their data's specific parameters and their meaning. They have told me very little else.

    How do I receive this data in my C++ program?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by ThisIsMe View Post
    The company says they will send the data using POST.
    What is the "POST" in this context?
    Victor Nijegorodov

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by VictorN View Post
    What is the "POST" in this context?
    Probably the POST request method supported by HTTP. See http://en.wikipedia.org/wiki/POST_%28HTTP%29
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How do I receive POST data in a C++ program


  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How do I receive POST data in a C++ program

    Well, I believe the first thing you need here is HTTP server (typically called web server) able at least to do HTTP POST processing. I would strongly recommend to have your web server and interface program separate from each other.

    Further design would depend on your dev team skills. For example, personally I would go with Apache + PHP + database, where Apache listens to incoming HTTP POST requests, PHP code extracts posted data parts and put those to database. Your "interface program in C++" would listen to changes in database and visualize those.

    In case of some other web skills a solution could be based on HTTP server implemented in C#. Depending on your design of handling data, database may be or may be not a part of your system.
    Last edited by Igor Vartanov; September 25th, 2014 at 02:21 AM.
    Best regards,
    Igor

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How do I receive POST data in a C++ program

    Best regards,
    Igor

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How do I receive POST data in a C++ program

    also:
    see C++ REST SDK a.k.a. "Casablanca" on codeplex https://casablanca.codeplex.com/
    which is a stand alone framework for C++ based web services without requiring a Webserver (IIS? apache...) running.
    the disadvantage is that for the time being, it'll require the POST data to be JSON. Other formats are for "later".

  8. #8
    Join Date
    Sep 2014
    Posts
    10

    Re: How do I receive POST data in a C++ program

    Perhaps I have led a sheltered life and I do not know even the basic stuff.

    My program needs to receive data sent to my program by POST. Does that mean I need to implement a web client or a web server? The code project article that you referenced describes a web client. Do I need to implement a client or server?

    Or am I messed up in my understanding?

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by ThisIsMe View Post
    Perhaps I have led a sheltered life and I do not know even the basic stuff.
    ...
    The code project article that you referenced describes a web client. Do I need to implement a client or server?
    What post do you mean?
    This one
    Quote Originally Posted by Igor Vartanov View Post
    gave you links to a web server examples/API
    Victor Nijegorodov

  10. #10
    Join Date
    Sep 2014
    Posts
    10

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by VictorN View Post
    What post do you mean?
    This one
    gave you links to a web server examples/API
    I should have used "reply with quote". I was replying to this "See this codeproject article: http://www.codeproject.com/Articles/...P-Wrapper-in-C"


    I still don't understand. Are you saying that I need to implement a web server. Please help me.

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by OReubens View Post
    also:
    see C++ REST SDK a.k.a. "Casablanca" on codeplex https://casablanca.codeplex.com/
    which is a stand alone framework for C++ based web services without requiring a Webserver (IIS? apache...) running.
    the disadvantage is that for the time being, it'll require the POST data to be JSON. Other formats are for "later".
    I was looking for this when I replied earlier, but forgot the code name. It's the way to go if it's a rest based interface.

  12. #12
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by ThisIsMe View Post
    I still don't understand. Are you saying that I need to implement a web server. Please help me.
    Ultimately, it doesn't matter what we're saying here. You have enough links to make your mind and understand what you need and choose a way to go. If you still don't, this just indicates that you are not prepared to handling this task, at least right away. Nothing outstanding, nobody is able to know everything.

    And yes, you need a web server. As you might notice, I already said this before.
    Last edited by Igor Vartanov; September 25th, 2014 at 02:09 PM.
    Best regards,
    Igor

  13. #13
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by Igor Vartanov View Post
    Ultimately, it doesn't matter what we're saying here. You have enough links to make your mind and understand what you need and choose a way to go. If you still don't, this just indicates that you are not prepared to handling this task, at least right away. Nothing outstanding, nobody is able to know everything.

    And yes, you need a web server. As you might notice, I already said this before.
    I misread the original requirements, so a web server is needed.

    At first I thought you are attempting to post data to the 3rd party's web server. After re-reading the OP, I see that the 3rd party needs to post data to you.

    For this you need a web server. So see post #6.

  14. #14
    Join Date
    Sep 2014
    Posts
    10

    Re: How do I receive POST data in a C++ program

    Quote Originally Posted by Arjay View Post
    I misread the original requirements, so a web server is needed.

    At first I thought you are attempting to post data to the 3rd party's web server. After re-reading the OP, I see that the 3rd party needs to post data to you.

    For this you need a web server. So see post #6.
    Thank you for helping me. Please understand that I don't yet understand some of the significance here. I am sure there is "meaning" and "understanding" that is way over my head. Please help me to understand.

    There are three entities.
    1) Me and my company. I am writing software for my company.
    2) My company's client who bought our software. Our software will be installed at this client, at their location and on their computer.
    3) A third party that will be sending occasional data using POST. It will be sent to my software. The software is at the client's location.

    Am I going to have to tell the third party what web address to send the POST data. Is that correct?

    That web address will be a web address of my client. Correct?

    Will I have to involve my client's IT department to allow this or set this up or something? Will this just work or are there issues?

    I am very confused.
    Lets say my client has a website "www.widget.com". They have a full web site setup there. So now one of their departments buys my software. My software needs to receive this POST data from a third party. How does this work? I just don't understand.

  15. #15
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How do I receive POST data in a C++ program

    It seems OP never listens to what I say, but anyway...

    Quote Originally Posted by ThisIsMe View Post
    My software needs to receive this POST data from a third party. How does this work? I just don't understand.
    Your software is not obliged to receive POST data. And any web server exposed to internet or customer's intranet can do that for your software by piping the received data to database. The database is very handy in this case, as it provides persistence for the data, and is able to collect the posted data even when your interface program is down. So you never miss a bit of the data because of being shut down. Besides, in this case the interface program just deals with database connection, which simplifies programming things a lot.
    Best regards,
    Igor

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured