Socket protocols for http

Hi. I'm trying to send a html form(that uses http POST method) data without clicking the submit button and instead sending the message through a c++ socket. Is that possible? How?
You could use a sniffer like wireshark to see what happens when you submit the html form from within your browser. Then you just need to open up a socket and mimic what you see with wireshark.

I'm assuming here, you do know how to work with sockets.
See RFC 2616. Page requests use GET, POST has a similar syntax.
http://www.w3.org/Protocols/rfc2616/rfc2616

If you're going to use a protocol, you really should try to understand it. Don't approach it by trying to reverse engineer it unless there's you have to.
Last edited on
Well, as you no doubt know, HTTP is a text-based protocol. So you "just" have to open a TCP/IP socket to the server and then send the appropriate strings to it and then handle the response. You just have to build your string correctly, as explained in the RFC kbw mentioned.

But there other things to deal with. So you should consider using libcurl or another http library (for example, if you're on Windows, WinINet) to do some of the work for you.

libcurl
http://curl.haxx.se/libcurl/

libcurl HTTP form POST example
http://curl.haxx.se/libcurl/c/postit2.html

Andy

PS We use libcurl and WinINet to do our HTTP related stuff at work, rather than coding everything from the sockets upwards.
Last edited on
Topic archived. No new replies allowed.